- This creates a new “merge commit”
- Hard for other developers to understand the history of the project.
- #Tenso: http://womanonrails.com/images/git-rebase/merge.png
$ git checkout feature
$ git merge master
- Single timeline
- Safety and traceability.
- Beautiful: https://fifthsurprise.files.wordpress.com/2014/02/merge-back-into-master.png?w=615
- The Golden Rule of Rebasing - when not to do it. The golden rule of git rebase is to never use it on public branches.
Simple way
$ git checkout feature
$ git rebase master
Interative
$ git rebase -i
Safe merge
$ git merge --no-ff
Adding parcialment
$ git add -p <file>
Reset to Head
$ git reset --hard HEAD
Reset to remote Head
$ git reset --hard origin/master
Checkout from remote file
$ git checkout origin/branch_name -- <path or file>
Fix commit
$ git commit --amend
Revert to some commit
$ git revert <commit_id>
Compare a unique file between two commits
git diff <commit_id> <commit_id> <file>
$ git stash save "Xablau"
Recover and delete stash
$ git stash pop
Log with files
git log --stat
Log with file and filter by file type
git log --stat -- "*.js"
git lg
~/.gitconfig
[alias]
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"