首页 > 解决方案 > git push 显示所有最新信息

问题描述

git新手在这里,曾经subversion:我已经提交了一些本地更改,现在想要推送,但我得到了:

$ git push
Everything up-to-date

快速谷歌搜索后,我发现:git push 说一切都是最新的,即使我有本地更改并且我认为很棒!并开始遵循已接受答案中的建议:

$ git log -1
#got the hash key
$ git checkout master
M       util/logging/cp_logging.cpp
Already on 'master'
Your branch is up-to-date with 'origin/master'.
#Now I got nervous and verified with git status 
#and git diff that my changes were still there
#just for safety I did a
$ git diff >save.patch
#followed by(as recommended):
$ git reset --hard 579823db25d2a821c2940608e9cb8122c2779b37
HEAD is now at 579823d Merge remote-tracking branch 'upstream/master'
#then I did a 
$ git status
# and realized that my changes were gone!

如何让我的更改(幸运地保存 save.patch)回到我的本地工作副本,然后从这里将更改推送到在线存储库?我的更改是否应该已经提交到我的本地仓库中(就像我之前所做的git commit那样)?

标签: gitpushcommitpatch

解决方案


那是我 9 年前的回答,只有当你的 git 状态显示你不在任何分支上时(分离的 HEAD)

无论如何,您可以使用git apply重新应用您保存的补丁。

然后添加、提交和推送。


推荐阅读