git pull: keeps telling me to stash local changes before pulling

后端 未结 2 720
情歌与酒
情歌与酒 2021-02-03 12:27

When I am trying to pull my git repository with \"git pull\", it keeps telling me that I have local changes although I have not touched any of the mentioned files. Can someone e

相关标签:
2条回答
  • 2021-02-03 13:11

    Git simply can't pull the changes if the files you have edited locally were changed on the remote. Basically, you have two choices:

    • stage and commit your changes, then Git will try to merge it during the pull (or ask for your help);
    • stash the changes, which puts them aside so you could pull the remote code and then re-apply your modifications.
    0 讨论(0)
  • 2021-02-03 13:25

    It sounds like your local branch does not have all of the changes on origin.

    Firstly, stash your changes

    git stash
    

    Then, pull in the changes from origin.

    git fetch origin && git rebase origin/(branch name)
    

    Next, add the stash back in to your working directory:

    git stash pop
    
    0 讨论(0)
提交回复
热议问题