Reputation: 838
I have started working on the develop branch in several files, and then realised that I should have created a new branch for it.
I have not committed the changes and the new files yet. so, how can I leave the develop branch as it was (revert?) and then copy the changes into the feature/test, which was meant to be the branch that I should be working on?
Upvotes: 2
Views: 106
Reputation: 5595
If you haven't committed anything, then all you have to do is checkout a new branch git checkout -b newbranch
, keep doing your work and then commit it on that branch.
Until you commit, your develop branch still is as it was. No reverting necessary. Also, you probably meant reset
rather than revert
. A reset moves the HEAD, a revert creates a new commit that exactly undoes a given commit.
Upvotes: 3
Reputation: 17712
Stash your changes:
git stash --include-untracked
Create a new branch and switch to it:
git checkout -b my-new-branch
Pop your changes:
git stash pop
Potentially make further changes, then when ready, add and commit all your changes as usual.
Upvotes: 2