![]() I expected “git pull -r” to erroneously bring commit ‘ e‘ back. ![]() She ran “git rebase –interactive origin/master” and marked every commit as “pick,” except commit ‘ e‘, which she marked with “drop”. origin/feature dropped a commitFor some reason Evangeline decided she wanted to drop commit ‘ e‘ from origin/feature.I also did not expect “git pull -r” to handle this one, but I was wrong here, too. This squashes feature down to a single commit, but leaves the merge-base alone (commit ‘ b‘ in this case). In the interactive screen she marks the first commit as “pick” and every other commit as “squash” or “fixup”. Evangeline types “git rebase –interactive origin/master”. She probably did this via “git merge –squash.” I did not expect “git pull -r” to be able to handle this, but I was wrong. Evangeline takes all work on feature, squashes it down to a single commit, and rebases it on top of origin/master. origin/feature squash-merged (with origin/master).The rebase notices that older commits ‘ d‘, ‘ e‘, and ‘ f‘ on Gabriel’s feature branch are patch-identical to the rebased ones on origin/feature, and thus it only replays the final ‘ gf’ commit. This is the canonical example of why we prefer “git pull -r”. origin/feature rebased (against origin/master).Since Gabriel does not push back in these scenarios, his ‘ gf‘ commit remains confined to his local feature branch. The graph on the right shows the result of Gabriel typing “git pull -r.”Ī scenario is deemed successful if “git pull -r” results in Gabriel’s _‘_ gf‘ commit sitting on top of origin/feature. The graph on the left shows both the state of origin/feature (thanks to Evangeline’s force-push), as well as the state of Gabriel’s local feature and how it relates to Evangeline’s force-push. Some people claim “git fetch git rebase origin/master” is equivalent to “git pull -r”, but it isn’t.įor each scenario, we are on Gabriel’s local branch feature. Important: we only use “git pull –rebase” (or -r).Perhaps “git pull –rebase” behaves differently in other versions. We only tested Git v2.14.1 and Git v1.7.2 for this experiment.This is a reasonable assumption since git sets this up by default when a user first types “git checkout feature”. We assume Gabriel has correctly set up remote tracking for his local feature branch.For each scenario, we want to see if Gabriel can use “git pull –rebase” to correctly reconcile his work (his ‘ gf‘ commit) against Evangeline’s most recent push. Meanwhile, Gabriel has already made his own ‘ gf‘ commit to his local feature branch. In each scenario, Evangeline rewrites the history of origin/feature with a force-push of some kind, usually incorporating her own ‘ ef‘ commit into her push. git commit -m 'gf' -author=' checkout -b evangeline/feature HEAD~1Įcho 'ef' > ef git add. R_ecreate it using the script below.Įcho 'a' > a git add. Note: ‘evangeline/feature’ is actually Evangeline’s local ‘feature’ branch, and ‘gabriel/feature’ is Gabriel’s local ‘feature’ branch. Evangeline and Gabriel are working together on branch ‘feature’. ![]() The context is a feature branch that two people are working in parallel, where either person might force-push at any time. The context here is not a master branch that’s advancing. I was unable to confuse “git pull –rebase,” no matter how hard I tried. I tried squashes, merge-squashes, dropped commits, merge-base adjustments, and all sorts of other force-push craziness. Take two commits, look at their patch-ids, and if they’re the same, drop the local one.īut what about squashes and other force-pushes where git patch-id won’t help? What does “git pull -r” do in those cases? I created a series of synthetic force-pushes to find out. Thanks to the git patch-id command it’s easy to imagine how this mechanism might work. are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped).’ ‘Note that any commits in HEAD which introduce the same textual changes as a commit in HEAD. The official “git rebase” documentation attests to this: I’ve long known that “git pull –rebase” reconciles the local branch correctly against upstream amends, rebases, and reorderings. Conclusion: Time To Revise The Golden Rule Introduction ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |