2

I do commits into the local repo and it works fine. But when I push to the remote repo it fails:

$ git push origin master
Everything up-to-date

Linux writes 'Everything up-to-date' but in remote repo on github (successfully plugged in with SSH keys) there is only 11 days old stuff. What's wrong?

Update

here is the previous output after commit (ci = "commit -a")

$ git ci
[detached HEAD 5b42c77] updated with financial report to calculate for exact contractor and some with table layout for _analogs.php
 12 files changed, 3071 insertions(+), 110 deletions(-)
 rewrite htdocs/protected/controllers/FinancialreportController.php (61%)
$ git push origin master 5b42c77
fatal: 5b42c77 cannot be resolved to branch.
$ git push master 5b42c77
fatal: 'master' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git push origin 5b42c77
fatal: 5b42c77 cannot be resolved to branch.
$ git push 5b42c77
fatal: '5b42c77' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

Update 2

$ git checkout master
M   htdocs/protected/runtime/application.log
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 28 commits.
Igor Savinkin
  • 5,669
  • 8
  • 37
  • 69

1 Answers1

1

Make sure you are not in a detached HEAD situation, by checkout the result of git branch and git status.

A detached HEAD wouldn't be pushed, which would explain the "Everything up-to-date" message.

If it is, see "How to move master to HEAD?" for master:

git branch -f master HEAD
git checkout master

Or see other suggestions at "How to I “move” my commits from “no branch” to an actual branch?".

Considering that you are pushing explicitly master (git push origin master), you wouldn't need git checkout master.

But if you want to do other commits on top of master, then it is important that your current branch be master (and not directly a commit like before, as a "detached HEAD").
Hence the git checkout master.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • May i ask you of how to attach the HEAD to my master branch on server? – Igor Savinkin Oct 27 '14 at 10:38
  • @IgorSavinkin first, are you in a detached HEAD locally? – VonC Oct 27 '14 at 10:39
  • thank you. I've followed your suggestion, but what does it mean : `Your branch is ahead of 'origin/master' by 28 commits.` Does it mean in remote repo are still the old staff and i need to push again? – Igor Savinkin Oct 27 '14 at 10:44
  • why is `git checkout master` needed if i do not want to get old versions from remote but push present from local repo into remote? – Igor Savinkin Oct 27 '14 at 10:49
  • A git push is still needed here. – VonC Oct 27 '14 at 10:51
  • thank you. I've done it. But still what `git checkout master` does in this context? – Igor Savinkin Oct 27 '14 at 10:53
  • 2
    *detached HEAD* means that your *HEAD* currently points **directly** on a commit. Usually your *HEAD* should point on a branch which in turn points on a commit. `git branch -f master HEAD` ensures that *master* now correctly points at your most current commit while `git checkout master` updates *HEAD* to point at *master* instead of directly at a commit. All further commits will be made on master. – Sascha Wolf Oct 27 '14 at 11:27
  • To get a better understanding what exactly branching in git does you can take a look at the [Git Branching](http://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell) chapter of the gitpro book. – Sascha Wolf Oct 27 '14 at 11:28