0

So I finally set up my first Github repo, and the reason is that I have multiple working machines, and I'd like to have a way to sync up all my work somewhere. I have my project set up on Eclipse so I'm using EGit to connect to github.

I first shared my project on my main working machine(call this machine 1) to github, and then I imported the project form github on machine 2. On machine 2 I noticed there's something called "Remote Tracking", which contains one branch called 'origin/master'. I assume this is the main branch on github, and this is the branch I want to work with.

However, whenever I want to select it as my active branch, it'll ask me to create a new "Local" branch, where my changes go instead of the origin/master branch. The 'local' branch shows up as an individual branch on GitHub, and changes to that branch won't merge with master branch unless I tell it so

Does this mean if I choose to work on different machines, each machine will have to create it's own branch? I find that annoying because I'll always have go commit to local branch->manually merge 2 branches. Any way to commit to main branch directly?

4

1 回答 1

1

不,你不应该那样做。在第二台机器上从 github 克隆代码时,它应该已经创建了一个本地 master 分支跟踪 origin/master。所以,只需在master第二台机器上处理这个分支(这是默认分支),准备好后,push在服务器上运行它。

当回到您的第一台机器时,pull您将合并(或快进)来自本地master分支服务器的更改。进行一些更改,提交,再次推送。然后回到第二台机器,拉取服务器上的更改。

git 是一个复杂的野兽,你应该在使用它之前阅读教程。例如,请参阅http://git-scm.com/book/en

于 2013-11-12T18:53:44.260 回答