从分支添加git子树 [英] Adding git subtree from a branch

查看:615
本文介绍了从分支添加git子树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 git subtree add 添加一个repo(称为cow)到我的项目中。特别是,我想添加分支 stable (这不是 master 分支)。我试过:

I'm trying to add a repo (called cow) to my project using git subtree add. In particular, I'd like to add the branch stable (which is not the master branch). I tried:

git subtree add -P cow https://github.com/geoffryan/cow.git stable

但是,这返回了错误

'stable' does not refer to a commit.

我也试过:

I also tried:

git subtree add -P cow https://github.com/geoffryan/cow.git cow/stable
'cow/stable' does not refer to a commit.

和:

And:

git subtree add -P cow https://github.com/geoffryan/cow.git ca26d248a12c21264e32a2c212381cafb578c9fb
'ca26d248a12c21264e32a2c212381cafb578c9fb' does not refer to a commit.

哈希表示对于 stable中的最新提交分支。我在网上看到的使用示例都使用 master 作为提交,是否可以使用子树add 一个非主分支?

The hash was that for the latest commit in the stable branch. The examples of use I've seen online all use master for the commit, is it possible to use subtree add on a non-master branch?

推荐答案

这似乎工作

This seems to work

$ git remote add cow https://github.com/geoffryan/cow.git
$ git fetch cow
$ git subtree add -P cow cow/stable
Added dir 'cow'

我不明白如何直接使用命令资源库部分。

I don't understand how to use directly the command with the repository part.

这篇关于从分支添加git子树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆