Git tips
July 11, 2012
There are plenty of Git tips. These are my study reference and it’s always updated. I strongly recomend that you create your own ;-)
1. Partial commits
git add -p FILE
git commit -a
2. Submiting your branch
git branch my_branch
git checkout my_branch
## edit something ##
git push origin origin:refs/heads/my_branch
git push origin my_branch
## if you previously cloned the repo ##
# to others
git clone ...
git checkout -b my_branch origin/my_branch
# if you already cloned.
git pull --rebase origin my_branch
3. Checking new patches BEFORE applying it.
git fetch
git log origin/master
4. Alias
Suppose this command:
git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Setting an alias:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Now just:
git lg
5. Merge
if you are working on a repo and someone push some things and you aren't on "latest" commit
git pull --rebase
IS THE SAME AS
git fetch
git rebase origin/p6
6. Tags
git tag TAGNAME
git push origin --tags