Search code examples
gitrepositorypushgit-remote

Failure to push to remote repo in Git


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.

Solution

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