In what cases could `git pull` be harmful?

后端 未结 5 1719
庸人自扰
庸人自扰 2020-11-28 00:17

I have a colleague who claims that git pull is harmful, and gets upset whenever someone uses it.

The git pull command seems to be the canon

5条回答
  •  一向
    一向 (楼主)
    2020-11-28 00:36

    The accepted answer claims

    The rebase-pull operation can't be configured to preserve merges

    but as of Git 1.8.5, which postdates that answer, you can do

    git pull --rebase=preserve
    

    or

    git config --global pull.rebase preserve
    

    or

    git config branch..rebase preserve
    

    The docs say

    When preserve, also pass --preserve-merges along to 'git rebase' so that locally committed merge commits will not be flattened by running 'git pull'.

    This previous discussion has more detailed information and diagrams: git pull --rebase --preserve-merges. It also explains why git pull --rebase=preserve is not the same as git pull --rebase --preserve-merges, which doesn't do the right thing.

    This other previous discussion explains what the preserve-merges variant of rebase actually does, and how it is a lot more complex than a regular rebase: What exactly does git's "rebase --preserve-merges" do (and why?)

提交回复
热议问题