Git认为我有不可推卸的改变 [英] Git Thinks I Have Unpushed Changes

查看:110
本文介绍了Git认为我有不可推卸的改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几个月里,我已经注意到过几次,有些时候在推动我的远程回购(GitHub,虽然我认为不重要)后,我的本地git会相信它没有被推动的改变。在所有情况下,这些都是 在远程存在的变化。最近的时间是今天上午。我在工作的机器上执行了 git pull origin master ,以获取从家中创建的三个提交。然后,当我做了 git status 时,它显示了与未被推送到远程的本地更改相同的 三个更改。 b
$ b

通常,我只是删除本地存储库并从GH重新克隆它,但说实话,我已经厌倦了这样做。在共享此代码的4台机器之间,它开始变得愚蠢,我经常需要这么做。



这听起来对任何人都很熟悉吗?有没有更好的解决方案,而不是放弃并重新克隆?这发生在Mac OS和Linux系统上,所以我不认为它是特定于任何操作系统的。

运行 git pull origin master 不会更新远程追踪分支 origin / master 。这将导致git认为你有本地无改变。假设 origin / master 是您的默认分支,您可以只说 git pull git pull来源,它会更新该分支。或者你可以使用 git fetch origin 然后使用 git merge origin / master


I have noticed several times in the last few months, that sometime after pushing changes to my remote repo (GitHub, though I don't think it matters) my local git will believe the changes it has have not been pushed. In all cases, these are changes that do in face exist on the remote. Most-recently was this morning. I did git pull origin master on my machine at work to fetch three commits that were made from home. Then, when I did git status it showed the same three changes as local changes that have not been pushed to the remote.

Usually, I just delete the local repository and re-clone it from GH, but to be honest I'm getting tired of doing that. Between 4 machines sharing this code, it's starting to get silly how often I have to do this.

Does this sound familiar to anyone? Is there a better solution than to just blow away and re-clone? This has happened on Mac OS and Linux systems both, so I don't think it is specific to any OS.

解决方案

Running git pull origin master doesn't update the remote-tracking branch origin/master. This will cause git to think you have local unpushed changes. Assuming origin/master is your default pull branch you can just say git pull or git pull origin and it will update that branch. Or you could use git fetch origin followed by git merge origin/master.

这篇关于Git认为我有不可推卸的改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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