This blog post is personal reference to some git ressources I don't want to forget.
- Successfull Git Branching - A blog post that makes sense! It discusses HOW to do branching.
- 19 Git tips for Everyday user - Or "19 git tips your Grandpa can't agree more."
- Git Commit - on "How to write better git-commit message".
- A couple of best practices on Code Management
- Cookbook on Pull with rebase. Small, ready to use recipes.
Using gitignore to ignore (but not delete) files
#source http://stackoverflow.com/a/16442091 #Instead of .gitignore, file track in origin repo #Modification in local repo will never be marked changed git update-index --assume-unchanged <file> #revert this operation git update-index --no-assume-unchanged <file> git ls-files -v | grep '^h' #list such files #delete cached file #vi .gitignore and add <file> git rm --cached <file>
Checkout remote git branch
git fetch origin #fetch a branch git branch -v -a #show available remote branches #branch off remote branch(without switch) git branch remote_branch origin/remote_branch #branch off remote(with switch) git checkout -b remote_branch origin/remote_branch #from git: git checkout -b [branch] [remotename]/[branch]#remotename=origin git checkout --track [remotename]/[branch] #shorthand to previous git checkout [branch]#shorthand of previous shorthand git branch -vv #shows tracking branches
Reverting a commit
#-m 1 will get you the tree as it was in <commit-hash> #-m 2 will reinstate the tree as it was in <commit-hash-1> git revert -m 1 <commit-hash> git commit -m "Reverting commit that messed up." git push -u origin master
Reset or revert a specific file to a specific revision using Git?
git checkout <commit-hash> file/to/restore
"Resolve Git merge conflicts in favor of their changes during a pull?". 3
#by default -s recursive is applied git pull -s recursive -X theirs <remoterepo or other repo> git pull -X theirs <remoterepo or other repo> #or simply git pull -X theirs#in current repository