1

根据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(从一个远程的origin),然后执行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 的了解中缺少什么,以了解这种差异的原因

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

非常感谢您的阅读。

4

0 回答 0