Trying to understand "Git Rebase"
At what exact scenario I have to use Git Rebase ?
I am trying to understand this for the past three years but i could'nt. Have read many blogs, stackoverflow's Q&A about git rebase but i am not clear about that still. I know, this might be the duplicate question but i need to understand exactly what is that git rebase and when to use that.
Anyone, Please give me clear explanation. I have read the following lines in one of the blogs
"In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase."
I know what to do with the merge command. but, how rebase replaces merge command? Give me any flow of commands by explaining this is how the rebase replaces merge command. I think i can understand in such a way.
Sorry for my poor English.. Thanks in Advance.
This interactive tutorial is very good, try to do a few rebase lessons. I saw that few people actually understood rebasing learning from it.
Rebase does not replace merge, merge is to create new commit by "joining" few. Rebase is generally to moving commits around the tree, switching commits order and that stuff.
Based on my understanding, This is what the rebase does.
Scenario Explained:
1) I am currently in branch master.
2) Create branch A from master
3) Also, Create branch B from master
4) I let Developer named A to work on branch A. Dev A modifies code in branch A.
5) I let Developer named B to work on branch B. Dev B modifies code in branch B.
6) Now, Dev B thinks that he wants to merge Dev A's code right from being in his own branch branch B. (instead of doing checkout to branch A, pull the code from branch A, again checkout to branch B and do a git merge branch A. this is what git merge does ).
7) But, when Dev B runs " git rebase branch A " by being in his own branch, the head of branch B comes on top by merging branch A with branch B.
8) Now, if the Dev A thinks that he wants to merge Dev B's code. He has to do " git rebase branch B ". Now the head of branch B will be on top of the head by merging B's code (already merged with branch A) to branch A.
9) Now, flow of commit version will be in straight line. this is clean!!
Please correct me if my wrong.. Interested in learning more about GIT..
Thanks
链接地址: http://www.djcxy.com/p/45104.html上一篇: Git和Eclipse,合并,推进和提交
下一篇: 试图理解“Git Rebase”