开发者

Setting up a lab to experiment with GIT

I'm a newbie (like 6 months) Linux user.

I'm using Git for quite a while, and now I'd like to start learning more advanced stuff. What I'd like to learn is a variety of ways to handle/manage remotes.

So my question is — how can I setup a "remote" locally? Is it possible to create two folders, for example:

/home/my_user/git_experiment/remote_branch
/home/my_user/git_experiment/local_branch 

and set local_branch folder to track remote_branch开发者_如何学C folder just like if remote_branch would be a repo on GitHub?


A remote is just a clone which you have some way to access. Commonly it's accessed via the git protocol or http (for reading) and ssh or https (for writing), but filesystem access works just as well. All you need to do is clone your repo:

# clone project into project2
git clone project project2

The origin remote will automatically be set up in project2, pointing to project, just like you're used to. You could add a corresponding remote in project, pointing to project2, and try out whatever fetching and pulling you want to do.

If you want to try out pushing, make sure you make a bare clone to push into:

# the .git suffix is traditional for bare repos, since they're
# basically the .git directory of a normal repo
git clone --bare project project.git
cd project
git remote add bare-remote ../project.git
# now you've got a remote to push to

I'm not sure why you're naming them "local_brach" and "remote_brach" (is that meant to say "branch"?). These aren't branches. They're clones; they can have their own full sets of branches, probably with some corresponding.


It is possible, the <url> parameter to git remote can just be a path:

$ git remote add my-remote /home/my_user/git_experiment/remote_brach
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜