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

前端 未结 5 863
死守一世寂寞
死守一世寂寞 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:28

    As you already mentioned this is the way to do it. You can use it in alias to save you typing and to use shortcut or you can use it in a single line (can be an alias as well)

    git stash && git pull --rebase && git stash pop

    It will do the same thing as you done but in a single line (&&) and is you set as alias it will even be shorter.

    The following lines will display the incoming/outgoing changes before you pull/push

    git log ^master origin/master
    git log master ^origin/master
    

提交回复
热议问题