-Advanced
Commit Early, Commit Oftern!
$ git checkout feature
$ git merge master
OR
$ git merge master feature
Benefits:
* Existing branches are not changed in any way
* Preserve the complete history of your project and avoid the risk of re-writing public commits
Bad about Merge:
* Every time you merge, it will create a new commit for that, which can leads
to polluted history
$ git checkout feature
$ git rebase master
Moved the entire feature branch to begin on the tip of the master branch
Benefits:
* Get a clean project history
* Eliminates the unnecessary merge commits required by git merge
* Gives a perfect linear project history
Disadvantages:
* If you don’t follow the Golden Rule of Rebasing, re-writing project history
can be problematic
* Loses the context provided by a merge commit —
Never use it on public branches
rebased master onto your feature branch
pick 33d5b7a Message for commit #1
pick 9480b3d Message for commit #2
pick 5c67e61 Message for commit #3
# Rebase 2b4dba8..eb98833 onto 2b4dba8 (7 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
$ git checkout feature
$ git rebase -i master
$ git checkout feature
$ git rebase -i HEAD~3
Thanks