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,129,465
  • 480
  • 4,036
  • 4,755
Camit1dk
  • 392
  • 2
  • 17
  • 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,129,465
  • 480
  • 4,036
  • 4,755
  • I have not tried your solution because the issue is solved by answered provided by first answered. Thanks for your help. – Camit1dk Jan 31 '20 at 07:29