I’m currently trying to follow the small project based work-group mentioned in the Pro Git book : http://progit.org/book/ch5-2.html
So, here’s my set-up:
[Live Website Folder]
| |
| |
Developer1 Developer2
The way that I achieved that was I did the following:
- git init –shared=0777
- git clone /live/website developer1
- git clone /live/website developer2
I was able to successfully clone my project and I went into developer1 folder. Here I make changes to my file index.html. Once, I make these changes, I do:
git add index.html
git commit -m 'Modified index.html --developer1'
git push
Now when I go to my /live/website directory and do a git status, it correctly tells me that the file index.html is modified. When I do:
git add index.html
git commit -m 'Modified index.html by developer1'
It successfully makes the commit, but when I try to vi index.html, the file that I see is the original/un-modified one. I don’t see the changes made by developer1, within that file. Is this expected behavior?
What
git statusis telling you is thatindex.htmlis different to what is in the git index.After you push, your
/live/websiterepo contains the updatedindex.htmlin the index, but the oldindex.htmlin the working copy. You need to dogit reset --hard HEADfollowed bygit checkout -finside/live/websiteto reset the working copy to the same as the HEAD commit.I’d suggest that you modify your setup slightly. Add a
stagingrepository that is bare and push changes into that. Add a post-update hook that runsgit pull staging masterinside/live/website. This will ensure that the live website gets updated as soon as a commit is pushed in.In glorious ascii art:
EDIT: Updated to correct command sequence for fixing the working copy.