This question and others deal with this problem in Git, but I generally work only in the SourceTree IDE. I've done some work, but before committing it, I realizes it should be on its own branch. How do I do that without losing the work I've done?
Using the git checkout Command The git checkout -b <BranchName> command will create a new branch and switch to it. Moreover, this command will leave the current branch as it is and bring all uncommitted changes to the new branch.
using SourceTree: Double-click on develop in the BRANCHES list. Switch to the develop branch, so you can merge the change. Click the "Push" icon in the toolbar.
If you have uncommitted changes when you switch branches, they will be lost.
Just click on Branch Icon
Give Name to your branch
Click OK
Your code will automatically will sync on your new branch.
then, If you want to commit your code on that branch
just commit it on your newly created branch. (The one with BOLD)
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