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

2 Answers 2

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.

2
  • @Sachin yes, or you can checkout the master branch in source tree, and merge bugfix-z in SourceTree: same result
    – VonC
    Commented Aug 2, 2015 at 8:58
  • Thanks, I have fixed the issue.
    – Sachin
    Commented Aug 2, 2015 at 8:58
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.

2
  • In the terminal. You will find a terminal button on the right of the SourceTree toolbar. Button icon looks like >_.
    – GolezTrol
    Commented Aug 2, 2015 at 8:56
  • Thanks for the help. I have fixed the issue.
    – Sachin
    Commented Aug 2, 2015 at 9:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.