Skip to content

Instantly share code, notes, and snippets.

@Mr-Kumar-Abhishek
Forked from ozh/new empty git branch.md
Created February 23, 2019 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Kumar-Abhishek/db1e6803fd89bdcde0d637d92c4a2ee6 to your computer and use it in GitHub Desktop.
Save Mr-Kumar-Abhishek/db1e6803fd89bdcde0d637d92c4a2ee6 to your computer and use it in GitHub Desktop.
Create a new empty branch in Git
$ git checkout --orphan NEWBRANCH
$ git rm -rf .

--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.

You can then start adding files and commit them and they will live in their own branch. If you take a look at the log, you will see that it is isolated from the original log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment