Reputation: 480
I mistakenly worked on master branch,
How can i move my changes to my branch from master?
Thanks.
Upvotes: 2
Views: 501
Reputation: 16053
You can run the following commands from the root directory of your repository
git reset HEAD -- . #this will unstage all the files
git stash #this will stash all the changes
git checkout <your_branch> #this will switch the branch
git stash pop #this will apply all the stashed changes in <your_branch>.
#If there are conflicts at this point, resolve them, then do the following
git add -all
git commit -am "<your_commit_message>" #this will commit in new branch.
Note: statement after #
is a comment. It doesn't belong to the command & should be excluded when executing the command.
Upvotes: 3