how to become a git power user
TRANSCRIPT
GIT POWER USERIlmari Kontulainen
@kontulai
@deveoteam
#gitpoweruser
Viimeksi muokattu: 9. Tammikuuta 2015Luottamuksellinen
• Git Aliases
• Rewriting history
• Fast context switching
• Different merging strategies
Topics
Git aliases
• git config --global alias.co checkout
• git config --global alias.br branch
• git config --global alias.ci commit
• git config --global alias.st status
• git config --global alias.dc diff --cached
• git config --global alias.hist ‘log --graph --oneline --decorate --all’
• git config --global alias.unstage 'reset HEAD --'
• git config --global alias.last 'log -1 HEAD'
Git Aliases
• git config --global alias.helloworld ‘!echo “Hello world”’
• git config --global alias.hello ‘!f() { echo Hello $1; }; f’
• git config --global alias.co-recurse '!sh -c “git checkout $1 && git submodule update --recursive" -'
Execute any shell command with aliases
Rewriting history
• git commit --amend
• git rebase
• git rebase -i
Rewriting history
• Modify last commit
• Or simply edit the commit message
• Changes the commit commit
• Deveo prevents pushing changed history to master branch by default
git commit --amend
• Base the work on my branch to some other branch
• creates new commits
git rebase
https://git-scm.com/book/en/v2/book/03-git-branching/images/basic-rebase-1.png
git rebase
git rebase
git rebase -i
• Clean up the history of your feature branch
• pick
• squash, fixup
• drop
• edit or reword
Fast context switching
• git stash
• git stash --keep-index
• git stash --include-untracked
• git stash --all
• git stash --patch
Fast context switching
Different merge strategies
• regular merge
• -- no-ff / --ff-only (Deveo uses --no-ff)
• --squash
• merging multiple branches into one
Different merging strategies