Git is a fantastic developer tool but it’s a messy tool. Below is a collection of my notes and references, which I collected while trying to tame this beast.
- Git 101
- See git tree in terminal
- Once you get the basics, you would want to see the tree and branches of your repo. This is especially handy when you are working with remote servers like AWS, rackspace et al. View tree log in terminal: Link
- Quick command to see tree in terminal:
git config --global alias.tree 'log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cblue%d %Creset %s %C(bold)(%an)%Creset"'
- Merge Conflicts
- Once you have come this far, you will definitely face merge conflicts. Here is a definitive reference explaining how to fix merge conflicts: Link
- To check the status of local vs remote files (which branches are outdated etc):
git remote show
- Can use
git fetchtoo. Never use
git pull, it will fetch and merge whatever it wants to. Can fuck up things
- To check what changes will be made if you Fetch the remote
git diff HEAD /
- Use the following command to check the available diff/merge tools
git mergetool --tool=
- To use vimdiff install vim:
sudo apt-get install vimand then run the following:
git config --global diff.tool vimdiff git config --global difftool.vimdiff.cmd "vimdiff $LOCAL $REMOTE"
git difftoolto diff
- picked from: Link
- Some tricks
- Show branch name in the bash: Link