git pull --rebase

后端 未结 3 1702
时光取名叫无心
时光取名叫无心 2021-02-14 18:35

Start situation (no unpushed changes, > indicates the current branch):

o C [> master][origin/master]
|
o B
|
o A
|
...

After

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-14 19:04

    You can pull with rebase instead of merge - that's the way my team works and it works quite well.

    From "A few git tips you didn't know about":

    Because branch merges in git are recorded with a merge commit, they are supposed to be meaningful—for example, to indicate when a feature has been merged to a release branch. However, during a regular daily workflow where several team members sync a single branch often, the timeline gets polluted with unnecessary micro-merges on regular git pull. Rebasing ensures that the commits are always re-applied so that the history stays linear.

    You can configure certain branches to always do this without the --rebase flag:

    #make 'git pull' on master always use rebase
    $ git config branch.master.rebase true

    You can also set up a global option to set the last property for every new tracked branch:

    # setup rebase for every tracking branch
    $ git config --global branch.autosetuprebase always

提交回复
热议问题