Utilizing Git for multiple development places

十年热恋 提交于 2019-12-08 06:45:40

问题


I want to utilize git in my development workflow. I'm using Eclipse Juno. I'm coming from CVS, but see lots of benefits from distributed VCS. I'm reading Pro Git book, have read quite bit of it to start using it, but somehow something does not work the way I think it should to. I'm doing well with it on single machine, but fail when I do remote repository sync.

This is what I want to achieve:

I have two PC-s, HOME & WORK. I want to develop on both PC, so chose git to sync them as well. I created repository on the THUMB drive, and cloned it on HOME & WORK.

now, I want to develop on either HOME or WORK, commit locally, sync with THUMB, and then sync with another PC (HOME or WORK).

what commands should I issue to do this? (for example WORK -> THUMB -> HOME)


回答1:


Basic workflow is commit locally using:

$ git add .
$ git commit -m "Commit message"

Until done, then:

# Push the 'master' branch to the 'thumb' repository
$ git push thumb master

Now switch the thumb drive to the other pc and then:

# Pull from the 'thumb' drive into your local repo
$ git pull thumb master



回答2:


So in your case THUMB is like an online central repository. If you cloned both WORK and HOME from the THUMB, it should be set up as a remote named origin on both PC-s, which is great.

So now when you make changes on WORK, you need to git push. It should automatically push the changes you made to the origin, so in your case to THUMB.

Then on HOME you need to either git fetch and then manually merge your master with origin/master or git pull. This is a matter of preference and I am sure that Pro Git explains it better than I could.



来源:https://stackoverflow.com/questions/11792303/utilizing-git-for-multiple-development-places

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!