git:小项目工作 [英] git : Small project work
问题描述
我目前正在尝试遵循Pro Git书中提到的基于小型项目的工作组: http://progit.org/book/ch5-2.html
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
所以,这是我的设置:
[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
我能够成功克隆我的项目,然后进入developer1
文件夹.在这里,我对文件index.html
进行了更改.一次,我做了这些更改,我做了:
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
现在,当我进入/live/website
目录并执行git status
时,它正确地告诉我文件index.html
已被修改.当我这样做时:
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'
它成功进行了提交,但是当我尝试vi index.html
时,我看到的文件是原始/未修改的文件.我看不到该文件中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?
推荐答案
git status
告诉您的是index.html
与git索引中的内容不同.
What git status
is telling you is that index.html
is different to what is in the git index.
推送后,您的/live/website
存储库在索引中包含更新的index.html
,但在工作副本中包含旧的index.html
.您需要先在/live/website
内部执行git reset --hard HEAD
,然后执行git checkout -f
,以将工作副本重置为与HEAD commit相同.
After you push, your /live/website
repo contains the updated index.html
in the index, but the old index.html
in the working copy. You need to do git reset --hard HEAD
followed by git checkout -f
inside /live/website
to reset the working copy to the same as the HEAD commit.
我建议您稍微修改一下设置.添加一个空的staging
存储库,然后将更改推送到其中.在/live/website
内添加运行git pull staging master
的更新后挂钩.这样可以确保在提交提交后立即更新实时网站.
I'd suggest that you modify your setup slightly. Add a staging
repository that is bare and push changes into that. Add a post-update hook that runs git pull staging master
inside /live/website
. This will ensure that the live website gets updated as soon as a commit is pushed in.
光荣的ascii艺术中:
In glorious ascii art:
/live/website
|
|
/path/to/staging (bare)
| |
| |
dev1 dev2
已更新,以更正用于修复工作副本的命令顺序.
Updated to correct command sequence for fixing the working copy.
这篇关于git:小项目工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!