在尝试使用git子树找出良好工作流程时,我想跟踪上游分支(通常不同于
你可以看到不同的远程分支:
现在假设您定义了两个新的git子树来跟踪上游分支
现在我想从子树中获取最新更改。因此,我执行以下操作:
有没有一种简单的方法来猜测/检查用于设置子树的上游分支,以便我可以按照以下格式制作通用命令:
master
),以便在添加git子树时使用。更具体地说,假设您定义了以下远程并用它们进行了提取: $> git remote add -f easybuild-easyblocks https://github.com/ULHPC/easybuild-easyblocks.git
$> git remote add -f easybuild-easyconfigs https://github.com/ULHPC/easybuild-easyconfigs.git
$> git fetch easybuild-easyblocks
$> git fetch easybuild-easyconfigs
你可以看到不同的远程分支:
$> git show-ref | grep -v tags | grep easybuild
f4b4752bcadd5dd44aa74ee03f4bd19b75810bdb refs/remotes/easybuild-easyblocks/develop
49a1e893160c6c1d2ad50109265e55586c377c1e refs/remotes/easybuild-easyblocks/master
173aa5cabddf998e2ad672135752a33875095f8b refs/remotes/easybuild-easyblocks/v1.8.x
49a1e893160c6c1d2ad50109265e55586c377c1e refs/remotes/easybuild-easyblocks/v1.9.x
770c5246667d7741c02d4e1f4d4a50fb8cd3fcbe refs/remotes/easybuild-easyconfigs/develop
d8422c6f7aace405f1089f178edabb9316629d4b refs/remotes/easybuild-easyconfigs/master
5f3be9e2d5cbb2844ebf74ede15e2c30a8b12705 refs/remotes/easybuild-easyconfigs/uni.lu
0382ff527360f1baa192bb92597552cc379bba68 refs/remotes/easybuild-easyconfigs/v1.8.0.x
d8422c6f7aace405f1089f178edabb9316629d4b refs/remotes/easybuild-easyconfigs/v1.9.x
现在假设您定义了两个新的git子树来跟踪上游分支
develop
,其中一个是用于远程easybuild-easyblocks
(另一个是用于远程v1.8.0.x easybuild-easyconfigs
): $> git subtree add --prefix easybuild/easyblocks --squash easybuild-easyblocks/develop
$> git subtree add --prefix easybuild/easyconfigs --squash easybuild-easyconfigs/v1.8.0.x
您最终拥有一个干净的目录布局,其中easybuild/*
在不同的目录中分别保存了相应存储库的最新版本。
现在,我可以通过运行以下命令来检查所有分支的头提交哈希:
$> git branch -v -r --abbrev=40
easybuild-easyblocks/develop f4b4752bcadd5dd44aa74ee03f4bd19b75810bdb Merge pull request #314 from boegel/version_bump
easybuild-easyblocks/master 49a1e893160c6c1d2ad50109265e55586c377c1e Merge pull request #312 from hpcugent/develop
easybuild-easyblocks/v1.8.x 173aa5cabddf998e2ad672135752a33875095f8b Merge pull request #281 from boegel/1.8.2_release_notes
easybuild-easyblocks/v1.9.x 49a1e893160c6c1d2ad50109265e55586c377c1e Merge pull request #312 from hpcugent/develop
easybuild-easyconfigs/develop 770c5246667d7741c02d4e1f4d4a50fb8cd3fcbe Merge pull request #500 from fgeorgatos/contrib_qtop
easybuild-easyconfigs/master d8422c6f7aace405f1089f178edabb9316629d4b Merge pull request #544 from hpcugent/develop
easybuild-easyconfigs/uni.lu 5f3be9e2d5cbb2844ebf74ede15e2c30a8b12705 add Allinea-4.2-34164-Ubuntu-10.04-x86_64.eb
easybuild-easyconfigs/v1.8.0.x 0382ff527360f1baa192bb92597552cc379bba68 Merge pull request #473 from boegel/v1.8.0.x
easybuild-easyconfigs/v1.9.x d8422c6f7aace405f1089f178edabb9316629d4b Merge pull request #544 from hpcugent/develop
现在我想从子树中获取最新更改。因此,我执行以下操作:
$>git fetch easybuild-easyblocks # fetch latest changes of the remote before merging
$> git subtree pull --prefix easybuild/easyblocks easybuild-easyblocks develop --squash
$> git fetch easybuild-easyconfigs
$> git subtree pull --prefix easybuild/easyconfigs easybuild-easyconfigs v1.8.0.x--squash
有没有一种简单的方法来猜测/检查用于设置子树的上游分支,以便我可以按照以下格式制作通用命令:
git subtree pull --prefix <path/to/subtree> <subtree-remote> <subtree-branch> --squash
???