美文网首页
git orphan 分支

git orphan 分支

作者: 上帝爱睡觉_d0a7 | 来源:发表于2019-08-29 10:37 被阅读0次

一、orphan分支

应用场景:

将N个完全不同的项目作为N个分支放在同一个仓库中, 并且分支之间互不影响

(一)创建仓库, 并克隆到本地

# 假设创建的仓库叫StudyDemos
$ git clone https:github.com/Onekki/StudyDemos.git

(二)创建orphan分支, 命名为AndroidDemo

$ git checkout --orphan AndroidDemo

注意:

如果不在分支里提交东西, 这个分支其实没有创建

$ git branch 

master

(三)在分支上提交代码到AndroidDemo分支

$ git add .
$ git commit -m "first commit"
$ git push origin AndroidDemo

(四)以同样的方法可以再创建IOSDemo分支

# 创建完成之后

git branch

master
AndroidDemo
* IOSDemo

注意:

用checkout切换分支时, 本地文件系统会瞬间发生变化.

相关文章

网友评论

      本文标题:git orphan 分支

      本文链接:https://www.haomeiwen.com/subject/nzwbectx.html