F
F
Fengol2019-01-31 19:02:57
git
Fengol, 2019-01-31 19:02:57

What is the correct way to create a clean branch in git?

I need to create a new clean branch, but since this is not possible in git, I choose the closest configuration. Next, I create a new branch using the command git checkout --orphan new-nameand after that I make a minor change in any file and execute addand commit. Next, I will delete the file from what I thought was a new branch, but it is deleted from the branch I created the current one with. Is it supposed to be like that? How to create a new clean branch so as not to repeat the above?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitsliputsli, 2019-02-01
@Fengol

git checkout --orphan newbranch
git reset
git commit --allow-empty -m "init"

A new branch newbranch will be created, independent of the current branches and with 1 empty commit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question