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.- Switch to an Existing Branch
git switch branch-name
- Create and Switch to a New Branch
git switch -c new-branch-name
- Work on Your Branch
git add .
git commit -m "Describe your changes"
- Push Your Branch to Remote
git push -u origin new-branch-name
- Merge Changes from Another Branch
git switch your-branch
git merge main
- Resolve Conflicts (if any)
git add .
git commit -m "Resolved merge conflicts"
- Switch Back to Another Branch
git switch main
- 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