GIT push not pushing commits to remote

11,550

Solution 1

First of all carefully examine your configuration.

  1. Make sure you have pushed it really.
  2. Make sure you have pushed it to where you THINK you pushed it.

What can help you:

$ git log --full-history // is your commit really there?
$ git reflog // operation history
$ git remote -v // what are your remotes? 
$ git remote show DESIRED_REPO // do you have the remote repo you wanted to push to configured? the DESIRED_REPO?

Finally, make sure you are using RIGHT push notation:

  1. There is a difference between git push public and git push --repo=public. First pushes to public ALWAYS, second only if remote for branch you are pushing is not set.
  2. If your branch is named differently than it's remote counterpart, this can make a difference.

$ git push remote local_branch:remote_branch // I've made this error today by swapping places, with remote_branch:local_branch Git will not find the branch to update.

Hope this helps. In my case careful re-reading of manual while re-examining commands I've tried helped and revealed the problem (swapped branch names).

Solution 2

I was in the same situation a few minutes ago (which is why I wandered into this thread). Anwyay, I was able to solve it via git push origin master instead of just git push.

This happened after I created a new branch, started pushing to the new branch, then went back to the master branch and tried to push to that branch again.

Share:
11,550
Tom Cannaerts
Author by

Tom Cannaerts

Updated on June 04, 2022

Comments

  • Tom Cannaerts
    Tom Cannaerts over 1 year

    I have been working on a git repository and have been pushing my local changes to a remote server all the time... up until recently. When I do a git push, it says that everything is up-to-date. In reality, I'm already 3 commits ahead of the remote version and it's not getting my changes.

    I have tried the git log -1, git reset --hard solution posted on various places, but that doesn't solve anything. Do I need to change that number to reflect the number of commits that I am ahead?

    Say I have 5 commits, for brevetys sake named 1 to 5. My local version is at 5, the remote version is at 2. Gitk shows my MASTER at commit 5 and remotes/origin/master at commit 2. Do I need to git reset my local version to 2 (or 3, the first commit that was not pushed to remote)? What will happen to my changes? The git documentation says that --hard will discard any changes, will that mean that they will be lost completely? I would like to keep the commit history of these 3 commits, as there were quite some changes made.

    • positron
      positron over 10 years
      No. No. Don't do a reset hard. You'll lose changes. What does your .git/config file has for the branch you are trying to update in the server?
    • VonC
      VonC over 10 years
      What git branch returns? Are you in a detached head mode? stackoverflow.com/questions/3965676/why-did-git-detach-my-he‌​ad/…
    • Tom Cannaerts
      Tom Cannaerts over 10 years
      Git branch gives me this, were the ENGBE-X branches are indeed seperate branches. pastebin.com/pimwZjTr
    • Tom Cannaerts
      Tom Cannaerts over 10 years
      Assuming I'm on a detached head, how did I get there? I have been merging branches, so I assume it would be somewhere there. This is a listing of git log, where commit 32320e... is the last one in the remote. It doesn't really look special to me. pastebin.com/uJfaQ9WY . So, any ideas on how to fix this?
  • greendino
    greendino over 2 years
    ironically. i did push origin master. but still