0

Lete me have an example

  1. Alice creates topic branch A, and works on it
  2. Bob creates unrelated topic branch B, and works on it
  3. Alice does git checkout master && git pull. Master is already up to date.
  4. bob does git checkout master && git pull. Master is already up to date.
  5. Alice does git merge topic-branch-A
  6. Bob does git merge topic-branch-B
  7. Bob does git push origin master before Alice
  8. Alice does git push origin master, which is rejected because it's not a fast-forward merge.
  9. Alice looks at origin/master's log, and sees that the commit is unrelated to hers.
  10. Alice does git pull --rebase origin master
  11. Alice's merge commit is unwound, Bob's commit is pulled, and Alice's commit is applied after Bob's commit.
  12. Alice does git push origin master, and everyone is happy they don't have to read a useless merge commit when they look at the logs in the future.

In the above example git pull --rebase works perfectly fine but if point 9 is as below.

  1. Alice looks at origin/master's log, and sees that the commit is related to hers.

What needs to be done to resolve this as if we proceed with point 10,11 then

  • Will Bobs commit gets changed with Alice changes
  • Will bobs commit remains and alice changes gets discarded
  • will both commits stay together with some information of this
  • Will there be any conflict message

What should be the case and how to tackle this?

  • All the options are available to Alice. Rebase on top of master (after bob's commit) or merge as is. Either way, you'll need to deal with conflicts (if any). Personally, I'd pull, then rebase on master, and deal with the conflicts, for the cleaner commit history. Hopefully, bob added enough unit tests to help alice determine if her changes has broken bob's commit. – Michael Kang Jun 27 '17 at 04:22
  • Look at this answer and the corresponding link. https://stackoverflow.com/questions/18930527/difference-between-git-pull-and-git-pull-rebase. Bob's Commit will be present and alice's commit will have conflicts that need to be resolved and the rebased commit will have both Alice's changes + merge like changes. – Ramakanth Putta Jun 27 '17 at 04:30

0 Answers0