I
I
Irina2022-03-28 16:53:38
git
Irina, 2022-03-28 16:53:38

I forgot to create my branch, how not to lose my changes?

Such situation. I did a git pull on the master branch. Then you had to create your own branch
git branch myWork
, make your changes to the code, make a commit and push it to GitHub to create your myWork branch there.
But I forgot to create my branch before changing the code! Those. I changed all the code while in the local master branch and now I don’t quite understand how to do it right so that I don’t lose my code and commit to the master branch. Please tell me how to correct it. I haven't made a commit of my code yet.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
theArckady, 2022-03-28
@irikonova45

git checkout -b myWork
When you create a branch, changes will not be lost. And always, if there is a chance of losing changes, you need to copy the changed files to a separate folder outside the project. And then if anything to restore.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question