为什么检查指定本地分支名称的git中的远程分支与使用远程默认名称的行为不同?

时间:2013-03-14 18:30:24

标签: git

根据https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html的文件:

git checkout <branch>

  If <branch> is not found but there does exist a tracking branch in exactly
  one remote (call it <remote>) with a matching name, treat as equivalent to

    $ git checkout -b <branch> --track <remote>/<branch>

如果我随后拨打git checkout project/phpunit/trunk(来自来源的单个遥控器),则执行git remote show origin会给我:

Local branches configured for 'git pull':
  master                merges with remote master
  project/phpunit/trunk merges with remote project/phpunit/trunk
Local refs configured for 'git push':
  master                pushes to master                (up to date)
  project/phpunit/trunk pushes to project/phpunit/trunk (up to date)

但是,如果我想给我的本地分支调用一些不那么罗嗦的内容,而是根据文档建议的内容使用git checkout -b phpunit --track origin/project/phpunit/trunk,而后续git remote show origin给出:

Local branches configured for 'git pull':
  master  merges with remote master
  phpunit merges with remote project/phpunit/trunk
Local ref configured for 'git push':
  master pushes to master (up to date)

简而言之,拉动的跟踪是完整的,然而,创建推送的参考不是。

使用中存在这种差异并不一定让我感到困扰,但我想知道我对git的了解,以及原因对于这种差异。< / p>

如果一种基于远程跟踪分支创建和签出新本地分支的方法,但是使用不同的本地名称命名它:该方法是什么?

非常感谢您阅读。

0 个答案:

没有答案