I have cloned repository and have made some commits:
git clone ... git add git commit git add git commit git add git commit
Now I have realized that it will be better to move all my commits to another new branch. What is the best way to do it?
First, checkout the branch that you want to take the specific commit to make a new branch. Then look at the toolbar, select Repository > Branch ... the shortcut is Command + Shift + B. And select the specific commit you want to take. And give a new branch name then create a branch!
New Branches The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
Easy, check out your new branch, then move the old branch (let's assume master
and 3 commits were made) back:
git checkout -b my_new_branch git branch -f master HEAD~3
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