Cannot push commits to a remote repository – GitHub

I have an Android project I was working on in Eclipse. I created an account for myself on github and pushed code within the project to the online remote repository using the GitHub for Mac client. Subsequently, I made a couple more minor commits to the code and all went well.

Now the code has undergone some significant changes and when I try to commit using the Mac client, I get the following error message on Sync:
Sync Failed: Please commit all your changes before syncing.

To get around this, I tried the following:
1. Tried to use git push origin/master from the command line. This resulted in project/info/refs not found: did you run git update-server-info on the server?
2. I checked if the repository name, location etc. were all correct and they were.

My question(s):
1. There are a large number of .class files which show up in the Changes section. Why do they show up given that .class files are included in .gitignore? Now that they have shown up, is it necessary to select and commit them too?
2. What is the meaning of the error message above and how do I get rid of it?

After the following commands:
1. git ls-tree -r master | grep .class – this showed that .class files were also added to the repository.
2. git rm **/*.class to remove all .class files from the repository.
3. git commit -m "remove class files
4. git push origin master results in:

fatal: not found: did you run git update-server-info on the server?  

Also, running git status on the command line shows the following line:

# On branch master
# Your branch is ahead of 'origin/master' by 16 commits.

Is this something of concern?

I have been through a lot of threads on this topic and taken a look at stuff like SSH-keygen but I dont think that is the solution to my problem. I am a newbie to git and have used only cvs before, so please dumb-down your answers, if possible.

My .gitignore file:

# built application files

# files for the dex VM

# Java class files

# generated files

# Local configuration file (sdk path, etc)

# Eclipse project files

# Proguard folder generated by Eclipse

# Intellij project files








  • I lost my uncommited changes after I made a merge
  • Caution! Just lost nested child repo by doing checkout on parent
  • Git clone is incredibly slow on my Mac. How can I fix that?
  • GitLab showing computer name + router name as commiter name
  • Github for Mac: Pull Request Button is missing
  • github-for-mac not opening any windows on yosemite
  • Github “fatal: remote origin already exists”
  • GitHub: Find out if a git commit is included in a release?
  • 4 Solutions collect form web for “Cannot push commits to a remote repository – GitHub”

    It is possible that you have committed the .class files in the repository already. In which case git will keep tracking them even if you put *.class in the .gitignore file. Run git ls-tree -r master | grep .class. If that gives any output you have committed .class files. If so, try running git rm **/*.class and commit the change.

    You are not supposed to run git push origin/master you need to specify a remote and then (optionally) a branch. Now git will try to parse origin/master as a remote. Use git push origin master instead (use a space not a /). origin/master is a branch that you should not be changing yourself anyway.

    Besides you have *.class multiple times in your .gitignore. Multiple occurrences will not change the behavior of git.

    You first need to push the commits to your local repository and THEN push the commits to the remote one. This allows you to do very easy merges with the remote repository as every commit has a unique SHA id which is used to tell where your repository is in relationship to the remote repo.

    do the following:

    git add .
    git commit -m "your commit message"
    git push origin master    (NOT git push origin/master)


    Did you by chance change the name of the github repository? This SO question should shed some light.

    ‘ git commit . ‘ will commit all your changes.

    Maybe you can try it… ( I’m not sure, just an idea )

    The problem was that I was signed in to GitHub‘s Mac client using a personal ID. This personal ID was not registered as a collaborator on the project. Adding my personal account as a collaborator (an ugly work-around) solved the problem. I was able to commmit changes to the repository.

    Other suggestions which I found useful:
    – Removing .class files from the repository.
    To check if .class files were being tracked: git ls-tree -r master | grep .class
    To remove them from the repo and commit: git rm **/*.class followed by git commit -m "your message goes here"
    To push all changes: git push origin master.

    To be able to use git with multiple accounts, I found this account here to be very useful.

    Git Baby is a git and github fan, let's start git clone.