2

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

nwinkler
  • 52,665
  • 21
  • 154
  • 168
Sachin
  • 737
  • 1
  • 9
  • 23

2 Answers2

1

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.

Community
  • 1
  • 1
GolezTrol
  • 114,394
  • 18
  • 182
  • 210
1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250