当我试图用“git pull”拉我的git存储库时,它一直告诉我我有本地更改,虽然我没有触及任何提到的文件。有人可以解释这种行为并知道解决方案吗?
git status:
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
# (use "git pull" to update your local branch)
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: src/component/Provider.java
# modified: src/data/Cascading.java
#
no changes added to commit (use "git add" and/or "git commit -a")
解决了问题。实际上我的错误是没有注意到远程存储库已重置为以前的版本。然而,如果您遇到这种情况,Max Woolf解释的解决方案将起作用!
答案 0 :(得分:16)
听起来您的本地分支机构没有对origin
进行所有更改。
首先,存储您的更改
git stash
然后,从origin
拉入更改。
git fetch origin && git rebase origin/(branch name)
接下来,将存储重新添加到您的工作目录中:
git stash pop
答案 1 :(得分:1)