2

I've found this question on moving branch pointers without doing a checkout. Basically I want to know how to do exactly that, in SourceTree.

So for example, suppose I'm on a local branch feat/foo. I've got master too, and can fetch a few new commits from origin/master. Here's a screenshot:

sourcetree screengrab

I want to set my local master pointer from 77f97cf to 85c2fd7, where origin/master is pointing to as well, without switching branches or changing my working copy.

I've tried:

  • the context menu for the origin/master commit
  • the context menu for the master commit
  • looking through the menus
  • the extra options in the Fetch dialog
  • Google-fu that combines the info from aforementioned question and "sourcetree"

To no avail.

Is this possible in SourceTree?

4
  • the screenshot provide would be result of what u needed or its ur present state of commits ?
    – KOTIOS
    Commented Apr 14, 2017 at 9:03
  • It's easy enough from the command line, but I have no idea if it is possible at all from the GUI. (Hence my deep distrust of most GUIs, since most make it easy to do something, but impossible to do some other thing that whoever wrote the GUI did not think about in advance. :-) )
    – torek
    Commented Apr 14, 2017 at 9:10
  • @MyMasterPeice The screenshot provides the present state. My local master pointer is at an old commit, I want to move it to the one that origin/master is pointing too as well.
    – Jeroen
    Commented Apr 14, 2017 at 9:11
  • @torek Aye, I realize that. I do use the command line too at times, but I sometimes I'm using a visual tool like SourceTree and I'd hate to switch to another tool just for one little thing like this. Hoping there is a GUI solution too.
    – Jeroen
    Commented Apr 14, 2017 at 9:12

2 Answers 2

1
  1. Stash your changes in your branch foo
  2. checkout master (right click on master)
  3. In master branch, right click to commit which you want to reset your local repo
  4. click "reset master to this commit"
  5. choose your using mode. (if you have changes and you want to reset all choose 'hard')
  6. click ok
  7. change to your branch foo (right click on foo and checkout)
  8. merge master into foo (right click on master)

Your master will be changed to that commit and sourcetree will show you that you need to pull. After that you can merge your local master to your local repo.

4
  • Thanks for taking the time to answer. However, there is no "reset master to this commit" option, only "reset current branch to this commit". Also, don't your instructions imply that I do switch my working copy around (which I explicitly do not want)?
    – Jeroen
    Commented Apr 14, 2017 at 9:53
  • ok you can stash your changes firstly. Git doesn't merge if you can occur conflict. You can click stash in this branch. Change it to master and do what you need.
    – utkusonmez
    Commented Apr 14, 2017 at 12:52
  • But I don't want to stash and switch branches, that's the point of my question. The other question I linked to seems to suggest you can do so with the command line, I'm merely looking for the SourceTree equivalent, if it even exists.
    – Jeroen
    Commented Apr 14, 2017 at 13:10
  • I dont know if you can do it without switching your branches. You can work on only one branch in your local. You can merge master on remote and you can pull changes.
    – utkusonmez
    Commented Apr 14, 2017 at 13:15
0

I don't think it's possible in SourceTree, but it's possible in one command after clicking on the Terminal button. I often need this for submodules that I modify without first remembering to checkout a branch. See this answer:

https://stackoverflow.com/a/5471197/47078

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