git master repo
To discard local changes in git repository
git reset --hard
For submodules its a bit tricky.
Try updating the submodules if you think you did not make any local changes.
git submodule update --init
If it doesn’t work, hard reset all submodules
git submodule foreach git reset --hard
If none of it works
It probably means there are some hidden/gitignored files lying around in submodule repository directory. For example, I was seeing this and none of the above steps helped.
[email protected]:project$ git status # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # (commit or discard the untracked or modified content in submodules) # # modified: ReactiveCocoa (untracked content) # [email protected]$ git diff diff --git a/ReactiveCocoa b/ReactiveCocoa --- a/ReactiveCocoa +++ b/ReactiveCocoa @@ -1 +1 @@ -Subproject commit 6ce5f58a0545c69039f262eb3b08c0e0a0c2c413 +Subproject commit 6ce5f58a0545c69039f262eb3b08c0e0a0c2c413-dirty
I went ahead and inspected what was inside the ReactiveCocoa directory
[email protected]:project$ cd ReactiveCocoa/ [email protected]:ReactiveCocoa$ git status # Not currently on any branch. # Untracked files: # (use "git add <file>..." to include in what will be committed) # # .DS_Store
.DS_Store was the culprit. Deleting it fixed the annoying untracked content message right away.
[email protected]:ReactiveCocoa$ rm .DS_Store [email protected]:ReactiveCocoa$ cd .. [email protected]:project$ git status # On branch master # Your branch is ahead of 'origin/master' by 2 commits. #