how to check out against a remote git repository from command line

时间:2015-07-28 22:24:23

标签: git git-branch git-pull git-checkout bitbucket-server

I am having trouble understanding exactly how I need to create a local feature branch to put customizations into. I have consulted some online resources which only confuse me further.

I have created the remote branch via stash called feature/mycustomization for people to create pull requests against.

Now from command line do I have to do a git checkout -b to create a local branch from which to push the changes to feature/mycustomization? Also, does the name of my local branch have to match up with the remote branch due to convention?

Or is there a command which pulls the code from the remote branch feature/mycustomization created in step one and automatically creates the local branch?

I would appreciate some step by step instructions if possible.

Cheers, Bob

1 个答案:

答案 0 :(得分:0)

If the remote branch exists, then git checkout <branch_name> should be sufficient enough to both create the local branch and properly set its upstream tracking branch.

If it does exist but there is no remote tracking branch set for it (you can verify this with git branch -vv), then you'll have to do a bit more work.

On the branch, run the command git branch -u origin/<branch_name>.