Git:有没有一种简单的方法来设置新分支来跟踪远程分支?
通常的命令是:
git checkout origin/branch_i_want -b branch_i_want
Git 响应:
Branch branch_i_want setup to track remote branch branch_i_want from origin.
这很好。
我的问题很简单。大多数时候,本地创建的分支与远程分支具有相同的名称。是否有 git 命令可以执行此操作,这样我就不需要输入两次分支名称?
换句话说,是否有类似的东西:
git checkout --autocreate-tracking origin/branch_i_want
理论上,这会创建一个名为branch_i_want 的本地分支并将其设置为跟踪 origin/branch_i_want ?
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 not 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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用最近的 git (我认为 >= 1.7),您只需执行
git checkout -t remotename/branchname
即可,并且隐含-b Branchame
。With recent git (I think >= 1.7) you can just do
git checkout -t remotename/branchname
, and-b branchame
is implied.