git本地分支创建后关联远程分支

在使用git创建本地分支时,可以在创建分支时就设置好跟踪的上游分支:

git checkout -b local_branch -t upstream_name/remote_branch

$ git checkout --help

       -t, --track
           When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.


           If no -b option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec
           configured for the corresponding remote, and then stripping the initial part up to the "*". This would tell us to use "hack" as the local branch when
           branching off of "origin/hack" (or "remotes/origin/hack", or even "refs/remotes/origin/hack"). If the given name has no slash, or the above guessing
           results in an empty name, the guessing is aborted. You can explicitly give a name with -b in such a case.


如果在本地分支时忘了关联上游分支,可以在创建好上游分支后使用命令:

git branch --set-upstream-to=upstream_name/remote_branch

$ git branch --help

       -u <upstream>, --set-upstream-to=<upstream>
           Set up <branchname>'s tracking information so <upstream> is considered <branchname>'s upstream branch. If no <branchname> is specified, then it defaults
           to the current branch.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值