Update: I think this is related to an issue with the windows git client msysgit. Sorry to trouble you guys. http://code.google.com/p/msysgit/issues/detail?i
I'm assuming you have a good reason for using Git for this, rather than rsync.
This is how I'd do it (on the Clients):
git fetch origin
git reset --hard origin/master
git clean -dfx
Note that you need to reset to origin/master
rather than HEAD
because the local HEAD
doesn't include the origin's newest commits (yet).
The following two commands should reset the client's working tree to a clean state, i.e. identical to how it was following the preceding git clone
:
git reset --hard HEAD
This will undo any modifications made to files which are tracked (i.e. which exist in the repo).
git clean -fdx
This will remove any files which have been newly created by the client, i.e. which are not tracked by git.
It's strange, git reset --hard
should remove any change made in the local repositories.
you can try git stash && git pull
, it just move the changes in some kind of temporay branch (git stash clear
to remove any trace of the changes)
if that does not work, you can try this (assuming you are on the master branch and that the tmp branch does not exists)
git checkout origin/master -b tmp
git branch -D master
git branch -m master
For the record, this original issue seems to be limited to msysgit 1.6.5.1 (issue 379), as mentioned by the OP.
However, that same issue mentions in 2012 a similar problem with other causes:
For the record, I have this issue with autocrlf = false.
Performing a git reset --hard
still leaves uncommitted changes relating to file permissions:
$ git reset --hard
HEAD is now at 088c702 BranchA
$ git diff
diff --git a/path/to/file b/path/to/file
old mode 100755
new mode 100644
...
This is in relation with "Removing files saying “old mode 100755 new mode 100644” from unstaged changes in git"
I've discovered that for some reason, core.filemode was set to true on repository level (I didn't set it myself):
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
So: git config core.filemode false
is recommended.
It sounds like you are looking for rsync, not git. Can you explain a bit more why you would want to use a full revision control system to "merely" keep some files in sync?