I don't know how to make an empty branch, whenever I make a branch, all of the 'master' branch items gets putted in the new branch...
Asked
Active
Viewed 3,549 times
0
-
This is a normal and natural thing in Git: in general, a commit tends to be on *many* branches. (This is in strong contrast to most VCSes where each commit is on *exactly one* branch. In Git, a commit can be on one, two, a thousand, or even *no* branches. This is because, in Git, branch *names* are merely moveable labels for one *specific* commit: the commit to which a branch label currently points is the *tip* of that branch. A new branch name is a new label pointing to some commit—usually the current commit. You can pick another commit or use the special `--orphan` option as shown below.) – torek Nov 06 '16 at 23:20
2 Answers
1
Visual studio can't do this from its built-in GUI, but you can easily do this from the command prompt.
Then the steps are straightforward.
You can create a branch as an orphan:
git checkout --orphan <branchname>
This will create a new branch with no parents. Then, you can clear the working directory with:
git rm --cached -r .

Community
- 1
- 1

Jeff Puckett
- 37,464
- 17
- 118
- 167
0
A branch is meant to be a fork of the code in master
. It sounds like you're after a new Repository:
This will be a blank new master
in a new Repository, with probably a .gitignore
file.
master
is only a convention, you can rename your master branch to anything you like.

DaveShaw
- 52,123
- 16
- 112
- 141
-
3in my case i want a blank branch so I can create a pull request from master into it so I can do a code review on existing code. my solution in the end was to branch off the initial commit as it contained very little. – Betty Mar 28 '18 at 20:03