我有一个公共(public)存储库。没有其他人对它进行 fork 、 pull 或做任何其他事情。我对一个文件做了一些小改动,成功提交,并尝试推送。它说“一切都是最新的”。没有分支机构。我对 git 非常非常陌生,我不明白到底发生了什么。
git remote show origin
告诉我:
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
有什么想法可以让我明白它不是最新的吗?
谢谢
更新:
混帐状态
:
# 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
:
* master remotes/origin/master
git fsck
:
dangling tree 105cb101ca1a4d2cbe1b5c73eb4a238e22cb4998 dangling tree 85bd0461f0fcb1618d46c8a80d3a4a7932de34bb
更新 2:我重新打开修改后的文件,我知道我所做的修改消失了。所以我再次添加了它们,完成了 git status
、git add filename
、git commit -m "(message)"
的繁琐操作,以及git push origin master
,突然间它按照预期的方式工作。
更新 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
最佳答案
尝试
git config push.default tracking
http://git-scm.com/docs/git-config :
推送默认值
定义 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.
关于git push 说一切都是最新的,但肯定不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4837290/