git push says everything up to date when it defini

2019-03-12 18:44发布

问题:

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 remote show origin tells me:

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:

# 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

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.

Update 3: git reflog output:

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

回答1:

Try

git config push.default tracking

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

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:

* 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.


回答2:

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.

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)



回答3:

Use

git push upstream yourlocalbranch:master

where yourlocalbranch could be master (which probably would be your local copy of origin master) or any other branch. If unsure use --verbose and --dry-run options.



标签: git push