rebase

Combine the first two commits of a Git repository?

女生的网名这么多〃 提交于 2019-11-25 23:28:56
Suppose you have a history containing the three commits A, B and C : A-B-C I would like to combine the two commits A and B to one commit AB : AB-C I tried git rebase -i A which opens up my editor with the following contents: pick e97a17b B pick asd314f C I change this to squash e97a17b B pick asd314f C Then Git 1.6.0.4 says: Cannot 'squash' without a previous commit Is there a way or is this just impossible? kostmo Use git rebase -i --root as of Git version 1.7.12 . In the interactive rebase file, change the second line of commit B to squash and leave the other lines at pick : pick f4202da A

What's the difference between 'git merge' and 'git rebase'?

痴心易碎 提交于 2019-11-25 20:02:28
What's the difference between git merge and git rebase ? Suppose originally there were 3 commits, A , B , C : Then developer Dan created commit D , and developer Ed created commit E : Obviously, this conflict should be resolved somehow. For this, there are 2 ways: MERGE : Both commits D and E are still here, but we create merge commit M that inherits changes from both D and E . However, this creates diamond shape, which many people find very confusing. REBASE : We create commit R , which actual file content is identical to that of merge commit M above. But, we get rid of commit E , like it