I just changed the README file and want to sync it in github, but it always tells me "You cannot sync with unstaged changes". Could someone tell me what it is and how should I fix this?
Asked
Active
Viewed 3.0k times
2 Answers
25
Look at learn.github:
You need to:
- add your file to the index (
git add
), - and commit it (
git commit -m "your modification comment"
), - before pushing it (
git push
).
See also "working with remotes")
So "unstaged changes" aren't linked to GitHub, but are local modifications on your local repo, which you haven't yet added to the index ("staged"), for a future commit.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
@VonC I'm facing same issue and my question is what if some one has made a lot of changes in his project say(i.e added new java classes, added some icons and also deleted few java classes e.t.c)?In my case i made some major changes to my android project where i deleted a java class and added 2 java classes,few icons. Then i copy pasted the whole new project to the git folder on my windows machine replacing the old one.Then i opened the native Git Hub app and tried to sync but got this message "Unstaged changes" You cannot sync with unstaged changes Pls commit your changes and then try again – Mohit Dec 11 '12 at 06:04
-
@Deadlock so couldn't you add and commit whatever git detects as untracked in `git status`? (also, check the status from a shell opened from the GitHub GUI: it will give you a more precise view of what is going on) – VonC Dec 11 '12 at 06:40
-
@DacSaunders Thank you. I have restored the link. – VonC Nov 21 '17 at 13:02
-
"...which you haven't yet added to the index ("staged").." does it mean git add operation is not yet done on that file ? – vikramvi Feb 25 '21 at 10:28
-
@vikramvi Yes: `git add` is required to stage the file, to add it to the index. – VonC Feb 25 '21 at 10:31
-
@VonC so per my understanding staging the file is same as adding it to the index right ? – vikramvi Feb 25 '21 at 10:33
-
1@vikramvi Yes, see https://stackoverflow.com/a/34179779/6309. – VonC Feb 25 '21 at 10:35