Reputation: 450
I just need to create a new branch without copying the master branch which is already in repo.
Is there any way to create a separate branch which has separate code in the same repo?
Upvotes: 3
Views: 2807
Reputation: 1329712
Since Git 2.23, you would use the new (still experimental) command git switch
.
In your case: git switch --orphan newBranch
Create a new orphan branch, named
<new-branch>
.
All tracked files are removed.
That branch won't have any common file/history with master
.
(Before 2.23, git checkout --orphan <new-branch>
, but using checkout is no longer recommended, since it deals both with files and branches)
Upvotes: 3