git pull:一直告诉我在拉之前隐藏本地更改 [英] git pull: keeps telling me to stash local changes before pulling

查看:283
本文介绍了git pull:一直告诉我在拉之前隐藏本地更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用"git pull"拉动我的git存储库时,它会一直告诉我我有本地更改,尽管我没有碰过任何提到的文件.有人可以解释这种行为并知道解决方法吗?

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 explain this behavior and knows a solution?

git状态:

    # 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解释的解决方案将起作用!

Solved the problem. It was actually my fault not noticing that the remote repository has been reset to a previous version. Nevertheless if you experience this, the solution explained by Max Woolf will work!

推荐答案

听起来您的本地分支没有origin上的所有更改.

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

首先,存储您的更改

git stash

然后,从origin提取更改.

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

接下来,将存储库重新添加到您的工作目录中:

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

git stash pop

这篇关于git pull:一直告诉我在拉之前隐藏本地更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆