Git Subtree 的使用

Git Subtree 的使用

1、创建 subtree
git remote add -f <子仓库名> <子仓库git地址>
git subtree add --prefix=<子目录名> <子仓库名> <分支> --squash
1. 其中 -f 的意思是在添加远程仓库之后,立即执行fetch;
2. –squash 意思是把 subtree 的改动合并成一次 commit ,这样就不用拉去子项目完整的历史记录。–prefix 之后的 “=”也可以用空格代替。
git remote add -f Utils https://github.com/KoKoBoom/CommonUtils.git
git subtree add --preifx=Taki.Utils Utils mater --squash
2、从远程仓库更新子目录
git fetch <子仓库名> <分支>
git subtree pull --prefix=<子目录名> <子仓库名> <分支> --squash
:
git fetch Utils master
git subtree pull --prefix=Taki.Utils Utils master --squash
3、从子目录 push 到远程仓库
git subtree push --prefix=<子目录名> <子仓库名> master
git subtree push --prefix=Taki.Utils Utils master
本条命令实际是根据【【主项目.git】的子目录】更新你的引用的【子项目.git】,并不会把你本地的子目录push到你的【子项目.git】。所以执行此代码前,你最好提交了你项目的【所有更新】。
如果你用本条代码 push 不了,那么你就要执行一次【代码2】 然后解决冲突,再重新提交。

http://aoxuis.me/post/2013-08-06-git-subtree

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值