Cannot push commits to a remote repository - GitHub

12.1k views Asked by At

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?

EDIT 1:
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: https://github.com/user/project.git/info/refs 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
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/
*.class

*.class

*.class

*.jar

*.class

*.class

bin/dexedLibs/slf4j-android-1.6.1-RC1-e5ffa87f4686586f2e03d9069f131ba3.jar

*.class
4

There are 4 answers

0
Sriram On BEST ANSWER

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.

5
BENARD Patrick On

' git commit . ' will commit all your changes.

Maybe you can try it... ( I'm not sure, just an idea )

1
g19fanatic On

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)

EDIT

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

6
Honril Awmos On

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.