git push显示所有最新信息

时间:2018-09-27 02:39:32

标签: git push commit patch

git个新手,曾经subversion: 我已经做了一些本地更改,现在想推送,但是我得到了:

$ git push
Everything up-to-date

在Google进行快速搜索后,我发现:git push says everything up-to-date even though I have local changes,并认为 GREAT!,并开始按照接受的答案中的建议进行操作:

$ 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那样在本地存储区中提交?

1 个答案:

答案 0 :(得分:1)

这是我9年前的回答,并且只有当您的git状态显示您不在任何分支(独立的HEAD)上

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

然后添加,提交和推送。