我有一个公共存储库。没有其他人分叉,拉扯或做任何其他事情。我对一个文件做了一些小改动,成功提交了它们,并试图推送。它说“一切都是最新的”。没有分支。我对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)
我能做些什么来让它明白它不是最新的?
由于
更新:
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
:
* 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
的严格过程,突然之间它按照预期的方式运行。< / p>
更新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
答案 0 :(得分:14)
尝试
git config push.default tracking
http://git-scm.com/docs/git-config:
push.default
定义如果在命令行上没有给出refspec,在远程中没有配置refspec,并且命令行上给出的任何选项都没有暗示refspec,那么git push应采取的操作。可能的值有:
* 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.
答案 1 :(得分:12)
编辑:这似乎不是正确的解决方案,请参阅问题的评论。我要留下答案,因为git add而不是git commit -a提示可能会帮助将来的某个人。
您好,在您提交之前添加了吗?
之类的东西git add .
(别忘了点)
之前的
git commit -m "what you changed"
(我发现此网站对于开始使用很有用 - http://gitref.org/remotes/#push)
答案 2 :(得分:4)
使用
git push upstream yourlocalbranch:master
其中yourlocalbranch
可以是master
(可能是您的原始主文件的本地副本)或任何其他分支。如果不确定,请使用--verbose
和--dry-run
选项。