2. Agenda
● Who am I?
● GIT Anti-Patterns
○ Manual Merging
○ Copy-Paste Backup
○ Dumb Bug Hunting
○ Dumb Conflict
Resolution
○ Jumbo Commit
2
○ Messing with History
○ Divergent Master
○ Self Reviewing
● References
● Q & A
3. Software Engineer
Passionate Hacker
ArchLinux Zealot
FOSS Enthusiast
I’m fond of doing
things that last
and all that jazz.
Lucas Lira Gomes
3
contact@x8lucas8x.com
linkedin.com/in/x8lucas8x
facebook.com/x8lucas8x
youtube.com/X80lucas08X
twitter.com/x8lucas8x
x8lucas8x.com
github.com/x8lucas8x
14. Copy-Paste Backup
14
● Solution
○ Stash it
$ git stash
Saved working directory and index state "WIP on master: 049d078 added the index file"
HEAD is now at 049d078 added the index file (To restore them type "git stash apply")
15. Copy-Paste Backup
15
● Solution
○ Stash it
$ git status
# On branch master
nothing to commit, working directory clean
$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
16. Copy-Paste Backup
16
● Solution
○ Stash it
$ git stash apply
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#
# modified: index.html
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
19. Dumb Bug Hunting
19
● Solution
○ Manual Bitsec
$ git bisect start
$ git bisect bad BAD_SHA1_HASH
$ git bisect good GOOD_SHA1_HASH
Bisecting: 6 revisions left to test after this
[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing
20. Dumb Bug Hunting
20
● Solution
○ Manual Bitsec
$ git bisect good
Bisecting: 3 revisions left to test after this
[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing
$ git bisect bad
Bisecting: 1 revisions left to test after this
[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table
21. Dumb Bug Hunting
21
● Solution
○ Manual Bitsec
$ git bisect good
b047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commit
commit b047b02ea83310a70fd603dc8cd7a6cd13d15c04
Author: User1 <user1@example.com>
Date: Tue Jan 27 14:48:32 2015 -0800
...
22. Dumb Bug Hunting
22
● Solution
○ Automate Bitsec
$ git bisect start BAD_SHA1_HASH GOOD_SHA1_HASH
$ git bisect run make test arguments
...
23. Dumb Conflict Resolution
23
$ git pull origin master
...
$ git status
# On branch branchA
# You have unmerged paths.
# ...
# both modified: README.md
#
...
$ vim README.md
...
26. Dumb Conflict Resolution
26
● Solution
○ Use a mergetool
$ git mergetool
Merging the files: README
Normal merge conflict for 'README':
{local}: modified
{remote}: modified
Hit return to start merge resolution tool (kdiff3):
39. Divergent Master
39
● Solution
○ Use master as a carbon copy
$ git checkout -b branchA
Switched to a new branch 'branchA'
$ git branch -D master
...
40. Divergent Master
40
● Solution
○ Use master as a carbon copy
$ git branch -a
branchA
remotes/central/master
$ git checkout remotes/central/master
...