Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How do I create a git branch so that files I add to it are not added to master?

I want to create a git branch that will work independent of the master branch. I want all the code that is present in the master till now, but any further changes in the master should not reflect in the branch and any changes in the branch should not reflect in the master.

I used this command to create branch:

git branch test

But any file I add in master, I can see in test. And any new file added in test, I can see in master. How to avoid this? I did not use any --track option while creating the branch.

like image 847
user811433 Avatar asked Jan 27 '12 14:01


1 Answers

I think what you wanted was:

git checkout --orphan somebranch

this will create a somebranch with no history whatsoever, you can add which files you want to that one, and they might differ 100% from your previous branches.

like image 192
Valerio Avatar answered Sep 28 '22 07:09