Reputation: 862
I cloned the development
branch from a gitlab repo into my local machine(window). After that I was supposed to create a new branch from this development
branch by git checkout -b new_branch
but I forgot to do that and I did all the changes inside the development
branch itself. I just remember it while pushing(my bad).
Now I want to create new branch from this development
branch and want to keep all these changes of the development
branch(which are not pushed and should not be pushed) to this newly created branch. How can I do this ?
Upvotes: 0
Views: 657
Reputation: 520968
This is a very common mistake people make when using Git, and it isn't just beginners who do this by accident. Assuming you haven't yet committed your work, you might even be able to just checkout a new branch:
# from development
git checkout -b new_branch
Then, commit your work and you should be good to go. If, for some reason, you can't create a new branch from development
, another easy option would be to just stash your work, then create the branch and apply the stash:
# again, from development
git stash
git checkout -b new_branch
# from new_branch
git stash apply
Again commit your work when it is done to this new branch.
Upvotes: 1