In this presentation, I go through the basic flow of using git, some of the git commands with their advanced usages and at the latter part I discuss the best practices in using git.
4. *
*
We are no alone!
WSO2/product-as bill/product-as
john/product-as
John’s local filesystem
product-as
bob/product-as
Bill’s local filesystem
product-as
Bob’s local filesystem
product-as
9. *
*
git rebase
$ git checkout feature
$ git rebase master
๏ Cleaner commit history
๏ Rewrites the history!!!!
10. **
๏ Very powerful
๏ Clean the commit history before merging to master
branch
$ git rebase -i HEAD~10
Interactive rebase
# Commands:
p, pick = use commit
r, reword = use commit, but edit the commit message
e, edit = use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log
message
x, exec = run command (the rest of the line) using shell
d, drop = remove commit
17. **
$ git config --global alias.lo "log --oneline"
$ git lo
git alias
18. **
$ git checkout feature
$ git cherry-pick 5a63064
git cherry-pick
๏ It’s a new commit !!!!
19. **
$ git reflog
git reflog
๏ git log shows commits in ancestor order
๏ Reflog shows in the order you last referenced the
commits
20. **
$ git bisect start
$ git bisect good <good commit hash>
$ git bisect bad <bad commit hash>
$ git bisect reset
git bisect
๏ Used to find the commit that introduced a bug/fix
๏ Do a binary search of the commits
21. **
Git best practices
๏ Develop features in feature branches
๏ Commit often, perfect later, publish once
๏ Never change published history (it is possible with
push -f, but never ever do it)
๏ Keep your git tree clean (git pull upstream master --rebase)
22. **
Git best practices...
๏ A commit message has a subject and a body.
๏ Make the commit subject imperative
๏ Link to the JIRA/Git Issue ID
๏ WSAS-1169 : <commit subject>
๏ Resolves #21