开发者

Git: Is there a short way to setup a new branch to track a remote branch?

The usual command is:

git checkout origin/branch_i_want -b branch_i_want

Git responds with:

Branch branch_i_want setup to track remote branch branch_i_want from origin.

This is fine.

My question is simple. Most of the time, the locally created branch has the same name as the remote branch. Is there a git command that does this so I do n开发者_运维技巧ot need to type the branch name twice?

In other words, is there something like:

git checkout --autocreate-tracking origin/branch_i_want

Which would, in theory create a local branch named branch_i_want and set it up to track origin/branch_i_want ?


With recent git (I think >= 1.7) you can just do git checkout -t remotename/branchname, and -b branchame is implied.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜