git push 表示一切都是最新的,但绝对不是

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4837290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:58:20  来源:igfitidea点击:

git push says everything up to date when it definitely is not

gitpush

提问by Wolf

I have a public repository. No one else has forked, pulled, or done anything else to it. I made some minor changes to one file, successfully committed them, and tried to push. It says 'Everything up-to-date'. There are no branches. I'm very, very new to git and I don't understand what on earth is going on.

我有一个公共存储库。没有其他人对它进行分叉、拉取或其他任何操作。我对一个文件做了一些小改动,成功提交,并尝试推送。它说“一切都是最新的”。没有分支机构。我对 git 非常非常陌生,我不明白到底发生了什么。

git remote show origintells me:

git remote show origin告诉我:

HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

Any ideas what I can do to make this understand that it's NOT up to date?

有什么想法可以让我明白它不是最新的吗?

Thanks

谢谢

Updates: git status:

更新 git status::

# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
#       histmarkup.el
#       vendor/yasnippet-0.6.1c/snippets/
no changes added to commit (use "git add" and/or "git commit -a")

git branch -a:

git branch -a

* master
  remotes/origin/master

git fsck:

git fsck

dangling tree 105cb101ca1a4d2cbe1b5c73eb4a238e22cb4998
dangling tree 85bd0461f0fcb1618d46c8a80d3a4a7932de34bb

Update 2: I re-opened the modified file, and the modifications I KNOW I had made were gone. So I added them again, went through the rigamarole of git status, git add filename, git commit -m "(message)", and git push origin master, and all of a sudden it works the way it's supposed to.

更新 2:我重新打开修改后的文件,我知道我所做的修改消失了。所以我再次添加了它们,经历了、、 和的 rigamarole git status,突然间它按照它应该的方式工作。git add filenamegit commit -m "(message)"git push origin master

Update 3: git reflogoutput:

更新 3:git reflog输出:

009251 HEAD@{0}: commit: added copy/paste keybindings
06920f9 HEAD@{1}: commit: Minor .gitignore tweak
84aa30c HEAD@{2}: checkout: moving from master to master
84aa30c HEAD@{3}: checkout: moving from ec16cca979045547a5444e20f48ed468dee81dd4 to master
ec16cca HEAD@{4}: commit: Added keybindings for copy/paste
5c4a611 HEAD@{5}: commit: remember-mode keybinding to M-R
f3e4729 HEAD@{6}: commit: Correcting last push which wiped out some stuff
fa28a3e HEAD@{7}: checkout: moving from master to fa28a3ed80eb0c6d4375ae77060d5cb4143d6a8e^0
84aa30c HEAD@{8}: commit: Modified keybindings, added LaTeX hook
10e7718 HEAD@{9}: commit: Added a few keybindings
d62378b HEAD@{10}: commit (initial): first commit

回答by John

Try

尝试

git config push.default tracking

http://git-scm.com/docs/git-config:

http://git-scm.com/docs/git-config

push.default

push.default

Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line. Possible values are:

定义 git push 应该采取的操作,如果命令行上没有给出 refspec,远程中没有配置 refspec,并且命令行上给出的任何选项都没有暗示任何 refspec。可能的值为:

* nothing - do not push anything.
* matching - push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.
* upstream - push the current branch to its upstream branch.
* tracking - deprecated synonym for upstream.
* current - push the current branch to a branch of the same name.

回答by Tom

EDIT:This it seems is not the correct solution, see the comments to the question. I am leaving the answer because the git add rather than git commit -a hint might help someone in the future.

编辑:这似乎不是正确的解决方案,请参阅问题的评论。我留下答案是因为 git add 而不是 git commit -a 提示可能会在将来对某人有所帮助。

Hello, did you add before you commited? something like

你好,你提交之前添加了吗?就像是

git add .

(don't forget the dot)

(不要忘记点)

before the

之前

git commit -m "what you changed"

(I find this site useful for getting going - http://gitref.org/remotes/#push)

(我发现这个网站对开始有用 - http://gitref.org/remotes/#push

回答by bastian

Use

git push upstream yourlocalbranch:master

where yourlocalbranchcould be master(which probably would be your local copy of origin master) or any other branch. If unsure use --verboseand --dry-runoptions.

yourlocalbranch可能在哪里master(可能是您的原始母版的本地副本)或任何其他分支。如果不确定使用--verbose--dry-run选项。