3

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Dhaval Vaghela
  • 440
  • 4
  • 20
  • You had selected the right answer before. If you create a branch from master (as the wrong answer suggests), it won't be a separate branch. – VonC Jan 31 '20 at 07:27

1 Answers1

2

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)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250