【问题标题】:git push shows everything up-to-dategit push 显示所有最新信息
【发布时间】:2019-03-02 20:58:34
【问题描述】:

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

$ git push
Everything up-to-date

在 Google 快速搜索后,我发现:git push says everything up-to-date even though I have local changes,我认为 太棒了! 并开始遵循已接受答案中的建议:

$ 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 一样)?

【问题讨论】:

  • git apply save.patch。然后git reset --hard 相当于 git 的 nuke,因此当您在工作树周围进行更改时请小心使用。如果它是您正在玩的已提交内容,您可以使用各种技巧将其从硬重置中恢复,但对于尚未提交的内容则不能这样说。

标签: git push commit patch


【解决方案1】:

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

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

然后添加、提交和推送。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-12
    • 2019-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多