git使用<三>:新建空白分支

参考文章:

http://blog.csdn.net/playboyanta123/article/details/48975175

https://segmentfault.com/a/1190000004931751

前几天想到github新建一个repo,主要包括bare、u-boot、kernel、rootfs,一般做法是每一个建一个repo,但是这样使用起来不太方便,因为4个目录都属于同一个单板,所以想把所有目录都放在一起,网上搜索了下主要有两种方式,个人偏向下面这个

1.创建空白分支tst
git checkout --orphan tst
2.删除原来代码树下的所有文件
git rm -rf .
rm '.gitignore'
3.按照一般步骤添加文件和提交
git add xx
git commit -m "yy"

操作实例

ubuntu@ubuntu:tst$ git log ; git branch
commit 2679461d108bec87dc699fd5dd456c60637f6629
Author: ubuntu <ubuntu@ubuntu>
Date:   Mon Sep 4 20:46:31 2017 +0800

    master
* master
ubuntu@ubuntu:tst$ git checkout --orphan tst ; ls -a
Switched to a new branch 'tst'
.  ..  .git  README.md
ubuntu@ubuntu:tst$ git rm -rf .
rm 'README.md'
ubuntu@ubuntu:tst$ ls ; git branch
  master
ubuntu@ubuntu:tst$ echo "5678" > README.md
ubuntu@ubuntu:tst$ git add README.md ; git commit -m "tst"
[tst (root-commit) c4f618d] tst
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
ubuntu@ubuntu:tst$ ls ; git branch
README.md
  master
* tst
原文地址:https://www.cnblogs.com/Ethan-Gao/p/7475671.html