Focus on Working with rebase over merge and managing commit history. Long form commands are utilized for clarity (and recommended). Includes Graphical interface recommendations.
|
$ git fetch origin
|
|
|
$ git switch -c <branch name> origin/main
|
|
|
$ git branch -D main master
|
|
$ git fetch origin
|
|
Grab the latest from remote
|
|
$ git switch -c <branch> origin/main
|
|
Create a branch off the mainline
|
|
$ git rebase origin/main
|
|
Update branch to mainline
|
|
$ git worktree add <newpath> origin/main -b <hotpatch>
|
|
Create a new repo copy to develop a hotpatch
|
|
$ git cherry-pick <commit>
|
|
|
$ git rebase <branch name>
|
|
|
$ git rebase <commit>
|
$ gitk
|
$ git stash --include-untracked
|
|
|
$ git stash pop
|
|
$ git fetch origin
|
|
$ git rebase origin/main
|
|
$ git rebase --continue
|
|
$ git push [--force] origin <branch>
|
|
Include
--force on personal branch |
|
$ git push origin --delete <branch>
|
|
Delete Remote Branch
|
|
$ git commit --fixup HEAD
|
|
|
$ git config --global alias.fixup 'commit --fixup'
|
|
|
$ git commit --fixup <commit>
|
|
|
$ git commit --fixup :/<message>
|
|
|
$ git rebase -i <commit>~1
|
|
|
$ git config --global rebase.autosquash true
|
|
|
Fix Commit Message
|
|
|
$ git rebase -i origin/main
|
reword
|
|
Important Commit First
|
|
|
$ git rebase -i origin/main
|
Reorder lines
|
|
Combine Commits
|
|
|
$ git rebase -i origin/main
|
fixup
|
|
$ git rebase -i origin/main
|
squash
|
|
Break Apart Work
|
|
|
$ git rebase -i origin/main
|
edit
|
|
$ git gui
|
|
|
$ git add <file>
|
|
|
$ git commit
|
|
|
$ git stash push -m <message>
|
|
|
$ git stash apply stash^/<message>
|
|
$ git fetch origin --prune
|
|
|
$ git switch --detach origin/main
|
|
|
$ git branch --merged
|
|
|
$ git branch --delete <branch1> < branch2>
|
|
|
$ git push origin --delete <branch>
|
|
Hash
|
:/msg
|
|
Branch
|
<branch>:/msg
|
|
origin/branch
|
|
|
origin/main
|
<branch>
|
|
origin
|
<remote>
|
|
$ git push origin main
|
push <remote> <branch>
|
|
$ git fetch origin
|
fetch <remote>
|
|
$ git rebase origin/main
|
rebase <branch>
|
|
$ git rebase --abort
|
|
|
$ git merge --abort
|
|
|
$ git cherry-pick --abort
|
|
|
$ git reset --hard <commit>
|
$ git reflog
|
$ git reset --hard
|
|
|
$ git clean --force
|
|
|
$ git switch <branch> --force
|
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.