Error: Cannot pull with rebase: You have unstaged changes

前端 未结 9 1765
无人共我
无人共我 2020-12-07 07:33

I have started collaborating with a few friends on a project & they use the heroku git repository.

I cloned the repository a few days ago and they have since mad

相关标签:
9条回答
  • 2020-12-07 08:08

    When the unstaged change is because git is attempting to fix eol conventions on a file (as is always my case), no amount of stashing or checking-out or resetting will make it go away.

    However, if the intent is really to rebase and ignore unstaged changed, then what I do is delete the branch locally then check it out again.

    git checkout -f anyotherbranchthanthisone
    git branch -D thebranchineedtorebase
    git checkout thebranchineedtorebase
    

    Voila! It hasn't failed me yet.

    0 讨论(0)
  • 2020-12-07 08:13

    Do git status, this will show you what files have changed. Since you stated that you don't want to keep the changes you can do git checkout -- <file name> or git reset --hard to get rid of the changes.

    For the most part, git will tell you what to do about changes. For example, your error message said to git stash your changes. This would be if you wanted to keep them. After pulling, you would then do git stash pop and your changes would be reapplied.

    git status also has how to get rid of changes depending on if the file is staged for commit or not.

    0 讨论(0)
  • 2020-12-07 08:16

    Follow the below steps

    From feature/branch (enter the below command)

    git checkout master

    git pull

    git checkout feature/branchname

    git merge master

    0 讨论(0)
  • 2020-12-07 08:18

    This works for me:

    git fetch
    git rebase --autostash FETCH_HEAD
    
    0 讨论(0)
  • 2020-12-07 08:23

    First start with a git status

    See if you have any pending changes. To discard them, run

    git reset --hard
    
    0 讨论(0)
  • 2020-12-07 08:27

    You can always do

    git fetch && git merge --ff-only origin/master
    

    and you will either get (a) no change if you have uncommitted changes that conflict with upstream changes or (b) the same effect as stash/pull/apply: a rebase to put you on the latest changes from HEAD and your uncommitted changes left as is.

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