Git config
git config --global color.ui true
git config --global alias.s "status -s"
git config --global alias.lg "log --oneline --decorate --all --graph"
Git common
git log --patch
git reflog
git cherry-pick --edit 5321
git cherry-pick --no-commit 53212e5 55ae74
Git SUBMODULES
A Git repo inside a Git repo
git submodule add git@example.com:css.git
git submodule init
git submodule update
git push --recurse-submodules=check
git push --recurse-submodules=on-demand
git config alias.pushall "push --recurse-submodules=on-demand"
Git purging history
git filter-branch --tree-filter 'find . -name "*.mp4" -exec rm {} \;'
git -index-filter 'git rm --cached --ignore-unmatch passwords.txt'
git filter-branch -f --prune-empty -- --all
Git rebase
$ git checkout unicorns
Switched to branch 'unicorns'
$ git rebase master
First, rewinding head to replay your work on top of it..
- Save commits from unicorn to temp folder
Apply commits on top of master
git rebase -i HEAD~3
Replay commits
Git stash
git stash save | Modifications are "stashed" away
git stash apply | Bring stashed files back
git stash list
git stash list --stat
git stash apply stash@{1}
git stash drop | delete from list
git stash save --keep-index
git stash save --include-untracked
git stash branch gerbil-toys stash@{0}
shortcut
git stash | git stash save
git stash apply | git stash apply stash@{0}
git stash drop | git stash drop stash@{0}
git stash pop | git stash apply git stash drop
Fork flow
git remote add upstream <oath_to_repo>
git fetch upstream
git merger upstream/master master
git push origin master
Release branches
git checkout v1.1
git checkout -b rb1.1
<code fix>
git commit -m 'hotfix'
git tag v1.1.1 -mm 'hotfix v1.1.1'
git checkout master
git merge rb1.1 -m 'merge hotfix'
git branch -d rb1.1