I have edits to my working tree which I would like to continue working on in a branch. Will git checkout -b new_branch
wipe out my current changes to the working tree? If so, how do I create a new branch and switch to it without reverting my working tree?
Just do git checkout -b new_branch
. It will create the new branch with the changes in your working tree untouched.
If in the future you need to see whether Git would destroy something you haven’t committed yet (which it generally will never do), use git stash
to stow away your changes. It will not save files that Git does not know about but Git will also refuse to overwrite unknown files in case of checkouts and similar operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With