尽管我有本地更改,但git push会将所有内容都更新为最新版本 [英] git push says everything up-to-date even though I have local changes
问题描述
我有一个远程gitosis服务器和一个本地git存储库,每当我对代码做出重大更改时,我都会将更改推送到该服务器。
但是,今天我发现即使我有一些本地更改并提交到本地存储库,运行 git push origin master 时,它会说'全部最新,但是当我使用 git clone 签出远程服务器上的文件时,它不包含最新的更改。我只有一个名为master的分支和一个名为origin的远程服务器。
PS:
这是git在运行ls-remote时显示的内容,不确定是否有帮助
$ git ls-remote origin
df80d0c64b8e2c160d3d9b106b30aee9540b6ece HEAD
df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs / heads /掌握
$ git ls-remote。
49c2cb46b9e798247898afdb079e76e40c9f77ea HEAD
df80d0c64b8e2c160d3d9b106b30aee9540b6ece参/头/主
df80d0c64b8e2c160d3d9b106b30aee9540b6ece参/遥控器/来源/主
3a04c3ea9b81252b0626b760f0a7766b81652c0c参/标签/ stage3的
您不会使用(强调我的):
有时可以签出不在您的某个分支的提交。
最明显的例子是在标记的官方发布点检查提交,如下所示:
<$ p $
$ b
$ git checkout v2.6.18
早期版本的git不允许这样做,并要求您使用
-b
选项创建临时分支,但从版本1.5.0开始,上述命令分离您的HEAD
从当前分支中直接指向由标记指定的提交(v2.6.18
在上面的例子中)。
你可以在这种状态下使用所有的git命令。
创建合并。 b
您可以使用git reset --hard $ othercommit
来进一步移动,例如。
您可以进行更改并创建新的在分离的HEAD 之上提交。
您甚至可以使用git merge $ othercommit
。
$ b当您的HEAD分离时,您处于的状态不会被任何分支记录(这很自然---您不在任何分支上)。
这是什么意思是可以通过切换回现有分支来放弃临时提交和合并(例如git checkout master
)以及后面的git prune
或git gc $ c $如果你错误地做了这件事,你可以询问head的reflog,例如:
$ git log -g -2 HEAD
I have a remote gitosis server and a local git repository, and each time I make a big change in my code, I'll push the changes to that server too.
But today I find that even though I have some local changes and commit to local repository, when running git push origin master it says 'Everything up-to-date', but when I use git clone to checkout files on the remote server, it doesn't contain lastest changes. And I have only one branch named master and one remote server named origin.
PS: This is what git displays when running ls-remote, I'm not sure whether it helps
$ git ls-remote origin df80d0c64b8e2c160d3d9b106b30aee9540b6ece HEAD df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/heads/master $ git ls-remote . 49c2cb46b9e798247898afdb079e76e40c9f77ea HEAD df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/heads/master df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/remotes/origin/master 3a04c3ea9b81252b0626b760f0a7766b81652c0c refs/tags/stage3
解决方案You would not be working with a detached head by any chance ?
As in:
indicating that your latest commit is not a branch head.
$ git log -1 # note the SHA-1 of latest commit $ git checkout master # reset your branch head to your previously detached commit $ git reset --hard <commit-id>
As mentioned in the
git checkout
man page (emphasis mine):It is sometimes useful to be able to checkout a commit that is not at the tip of one of your branches.
The most obvious example is to check out the commit at a tagged official release point, like this:
$ git checkout v2.6.18
Earlier versions of git did not allow this and asked you to create a temporary branch using the
-b
option, but starting from version 1.5.0, the above command detaches yourHEAD
from the current branch and directly points at the commit named by the tag (v2.6.18
in the example above).You can use all git commands while in this state.
You can usegit reset --hard $othercommit
to further move around, for example.
You can make changes and create a new commit on top of a detached HEAD.
You can even create a merge by usinggit merge $othercommit
.The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
What this means is that you can discard your temporary commits and merges by switching back to an existing branch (e.g.git checkout master
), and a latergit prune
orgit gc
would garbage-collect them.
If you did this by mistake, you can ask the reflog for HEAD where you were, e.g.
$ git log -g -2 HEAD
这篇关于尽管我有本地更改,但git push会将所有内容都更新为最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!