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