This short presentation was a 20 minute talk for Barcamp 4 in Ghent (2011). The talk is about how to work better with GIT. Some tips and tricks and must-do's for people who already use git
4. ... and with the love from @github
If you don’t have a @github account yet, then this talk isn’t for you...
5. ... and with the love from @github
If you don’t have a @github account yet, then this talk isn’t for you...
6. 5 MUST-DO’s as git user
or you would better not start using git at all...
7. 1. Don’t use a GUI, ever! CLI ftw!
• You will never feel the power of GIT
• Not (almost) every command is possible through a GUI
OK, there are cool GUI’s but becoming an expert is easier the
hard way, the CLI-way!
9. 2. Configure git like it should be...
•$ git config --global color.ui true
•$ git config --global format.pretty oneline
•$ git config --global core.autocrlf true (Windows) use a
LF
$ git config --global core.safecrlf true (Windows) line lways
end
$ git config --global core.autocrl input (OSX & linux) ing
s!
•$ git config --global core.excludesfile ~/.gitignore
$ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore
• enable bash autocompletion (Google it for your OS)
10. 2. Configure git like it should be...
•$ git config --global color.ui true
•$ git config --global format.pretty oneline
•$ git config --global core.autocrlf true (Windows) use a
LF
$ git config --global core.safecrlf true (Windows) line lways
end
$ git config --global core.autocrl input (OSX & linux) ing
s!
•$ git config --global core.excludesfile ~/.gitignore DR
Y
$ printf ".DS_StorenThumbs.dbn._*n" >> ~/.gitignore
• enable bash autocompletion (Google it for your OS)
11. 3. Use a remote repo if possible
and probably many more...
12. 4. Use submodules when possible
• Better overview of different “parts” in your code
• DRY: Re-use repositories in every project trough submodules
Good example: Every module in the @kohanaphp framework is a
seperate repository, so different contributors and releases possible
13.
14.
15.
16. 5. Branch, branch and tag!
Choose your own workflow
Source: http://nvie.com/posts/a-successful-git-branching-model/
17. 5 TIPS that will reduce
the amount of WTF’s
and hopefully making you commit better then before
18. 1. Where’s my commit?
Oh no! It’s on a detached HEAD?!
•A problem with submodules “currently not on a branch”
• Search for your commits SHA-reference (eg. a8e358c)
$ git log -p
• Merge it with your branch
$ git checkout master
$ git merge a8e358c
19. 2. Use git merge --no-ff
You will not regret it if you want to revert it!
Source: http://nvie.com/posts/a-successful-git-branching-model/
20. 3. Use git add -i
Becomes sometime you do different things together...
22. 4. git submodule rm exists, right?
No!
$ vim .gitmodules
$ vim .git/config
$ git rm --cached path/to/module NO trailing slash!
Commit your changes
23. 5. I didn’t change my file but still...
git tracks file execution permissions too
2 Possibilities:
• Track no permissions
$ git config core.fileMode false
• Apply the permissions to the files without have it in your repo
$ git diff -p
| grep -E '^(diff|old mode|new mode)'
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/'
| git apply