Sachin
Sachin

Reputation: 765

Switch branch name on SourceTree

I was learning how to use SourceTree and git, and after experimenting I accidentally made a commit in the wrong branch, and it seems like my master branch is no longer the main branch.

Picture of my SourceTree graph

Here is an image of what my graph currently looks like. I was wondering it is possible for me somehow make bugfix-z branch my master branch

Upvotes: 2

Views: 2119

Answers (2)

GolezTrol
GolezTrol

Reputation: 116170

If you haven't pushed yet, you can easily revert the last commit using

git reset --soft HEAD~1

You can type in this command in the terminal (use the 'terminal' button on the right of the toolbar). enter image description here

After that you can switch to the master branch and commit the changes again.

Upvotes: 1

VonC
VonC

Reputation: 1328762

Considering master has been merged into bugfix-z, a consider simple

git checkout master
git merge bugfix-z

That would fast-forward master to bugfix-z HEAD.

Upvotes: 1

Related Questions