Can “git pull” automatically stash and pop pending changes?

前端 未结 5 860
死守一世寂寞
死守一世寂寞 2020-11-21 23:41

I know how to solve this:

user@host$ git pull
Updating 9386059..6e3ffde
error: Your local changes to the following files would be overwritten by merge:
    f         


        
5条回答
  •  太阳男子
    2020-11-22 00:22

    As the comment above stated, setting the two config values doesn't currently work with git pull, as the autostash config only applies to actual rebases. These git commands do what you want:

    git fetch
    git rebase --autostash FETCH_HEAD
    

    Or set it as an alias:

    git config alias.pullr '!git fetch; git rebase --autostash FETCH_HEAD'
    

    Then do:

    git pullr
    

    Of course, this alias can be renamed as desired.

提交回复
热议问题