Skip to main content

Git

Basic workflow​

Show

This outlines the basic .git workflow.

  • Create a local branch
git checkout -b my-feature
  • Make changes
git commit -m "feat: my feature description"
  • Push changes
git push
git push -u origin my-feature

Using git switch​

Show
git switch enhances branch management in Git, making it easier to switch between, create, and merge branches.
  1. Switch to an Existing Branch
git switch branch-name
  1. Create and Switch to a New Branch
git switch -c new-branch-name
  1. Work on Your Branch
git add .
git commit -m "Describe your changes"
  1. Push Your Branch to Remote
git push -u origin new-branch-name
  1. Merge Changes from Another Branch
git switch your-branch
git merge main
  1. Resolve Conflicts (if any)
git add .
git commit -m "Resolved merge conflicts"
  1. Switch Back to Another Branch
git switch main
  1. Clean Up
git branch -d new-feature
git push origin --delete new-feature

.gitconfig​

Basic​

Show
[user]
name = my_username
email = my_email@example.com
[init]
defaultBranch = main
[color]
ui = auto
[core]
editor = code

Extended​

Show
.gitconfig

# First things first, always set up your user info.

[user]
name = my_username
email = my_email@example.com


# Display colours in the console
[color]
ui = auto
branch = auto
status = auto

# Always rebase when using `git pull`, except for `main, master, develop` branches.
[branch]
autosetuprebase = always

[branch "main"]
rebase = false

[branch "master"]
rebase = false

[branch "develop"]
rebase = false



# Automatically set up remote tracking branches for all new local branches.



[push]
autoSetupRemote = true

# Important setting in windows that allows working on both Windows and cross-platform projects
[core]
eol = native
autocrlf = input

# Common typos and aliases for long commands
[alias]
chekcout = checkout
ocmmit = commit
statsu = status
sttaus = status
fa = fetch --all
pushf = push --force-with-lease
stsah = stash

# Common LFS Settings
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f

# How private registries are handled
[credential "https://my_company_vcs.example.com"]
provider = generic