I host a small development server on my system. From that working directory I created a bare git repo. From there myself and 1 other user pulled the repo to local systems.
I since thought the other user stopped using the git repo. So I was working directly on the working files directly “on the server” (which is my system).
Randomly this morning the other user pushed to the repo. BAM, all of my files were immediately removed. The entire folder structure was replaced with his copy.
I thought GIT was supposed to tell him – woah hey, these files don’t match! pull first! but it did nothing! just – BAM, remove all my work.
So now I am stuck, all of my files are gone – I checked the log on the repo and it shows his push – but it doesn’t mention a thing about removing my files – only adding his.
I should note that I setup the bare repo using some tutorials out there dealing with using a repo to directly control working files on a web server.as such the repo has the following post.update hook:
echo "***Updating Server Files***"
GIT_WORK_TREE=//myserver/myfolder git checkout -f
Are my files gone forever?
The
git checkoutman page has this to say about the-f(or “force”) flag forcheckoutthat you put in your post-update hook:If you had been still using a “local” repo and pushing yourself to update the server, you’d be fine no matter what your other user had done, because your local commits and files would be untouched.
But if, as it seems, you were just making changes directly, and ignoring the Git part of your setup, your changes are probably gone (barring any backups you might have made, of course). As far as Git’s concerned, all the stuff it wiped out was just “local changes.”