How to create a branch without adding all the existing files?

后端 未结 3 1732
天命终不由人
天命终不由人 2021-01-31 15:58

When I create branch in git, all the created files are added to the new branch.

How can I create a branch without adding all the existing files?

3条回答
  •  南旧
    南旧 (楼主)
    2021-01-31 17:02

    git checkout --orphan branchname
    git rm -rf .
    

    After doing that you can create, add, and commit new files and the resulting branch will have no common history with any other branches in your project (unless you merge them at some point).

提交回复
热议问题