【问题标题】:how to remote add a single branch from a repository如何从存储库远程添加单个分支
【发布时间】:2016-06-24 09:40:22
【问题描述】:

假设我们有一个带有 masterdev 分支的 Assets 项目 和另一个名为 TheProject 的项目。

我想远程添加only Assets 项目的dev 分支。

如果我想添加整个 Assets 项目,我会这样做:

#Add a new remote URL pointing to the separate project that we're interested in
git remote add -f ASSETS git@example/assets.git

#Merge the Assets project into the local Git project
git merge -s ours --no-commit ASSETS/master

#Create a new directory called ASSETS, and copy the Git history of the Assets project into it
git read-tree --prefix=ASSETS/ -u ASSETS/master

#commit the changes to your master branch
git commit -m "Subtree merged in spoon-knife"

git push

但无论如何,这不是我需要的。我的想法是这样的:

git remote add -f ASSETS --single-branch dev git@example/assets.git

但如果它有效,我现在就不会问了!有什么想法吗?

【问题讨论】:

    标签: git branch add


    【解决方案1】:

    实际上我发布的代码确实符合我的要求..

    git read-tree --prefix=ASSETS/ -u ASSETS/master
    #adds only the master branch
    
    git read-tree --prefix=ASSETS/ -u ASSETS/dev
    #adds only the dev branch
    

    问题解决了

    【讨论】:

      猜你喜欢
      • 2021-02-16
      • 2014-06-20
      • 2015-11-22
      • 2014-11-30
      • 2011-03-03
      • 2020-11-23
      • 2017-05-14
      相关资源
      最近更新 更多