0

This is how I move master to branchX in git:

$ git checkout master            #move HEAD to master
$ git branch -f branchX HEAD     #move by force, HEAD to branchX

Is there a way to do that in Magit?

In this example, I want to move master to wstudent-topic2:

enter image description here

2
  • 2
    I don't think that it does what you think it does... git branch -f <branchname> <startpoint> will reset <branchname> to commit <startpoint>. In your case, this will not affect master branch in any way. Instead, this will basically, alias master as branchX. I'm not sure why would you want to do it, and I never tried to do this from magit. Can you explain what's the end-result you want to achieve?
    – wvxvw
    Dec 25, 2017 at 9:56
  • @user2867994 You will have to explain what you mean by "move master to branch in magit". Currently it is impossible to tell for sure what you actually want to do.
    – tarsius
    Jan 7, 2018 at 17:47

1 Answer 1

2

It is not clear what you want to do but since my attempt to get you to explain in more detail what you want (or to get moderators of this site to close the issue because you don't do that) have failed, I am answering some questions that you did not actually ask.

Based on the screenshot (but for the most part ignoring what you have written) I am going to assume that your question is one of:

How do I merge topic2 into master?

Type m m topic2 RET.

If you put the cursor on the add f2 line first, then you could also just m m RET because topic2 would be the default in that case.

How do I reset master so that it points at the same commit as topic2?

In a situation like the one in the screenshot you should just merge topic2 as I have just described. But if the situation looked like this instead:

* [master] something else
| * [topic2] add f2
|/
* add f1
* add f0

Then a merge would result in this:

* [master] Merge branch 'topic2'
|\
| * [topic2] add f2
* | something else
|/
* add f1
* add f0

Maybe that's what you want - I have no way of knowing. But if you want this instead:

* [master] [topic2] add f2
* add f1
* add f0

then move to the [topic2] add fs line and type C-u x RET.

1
  • 1
    @user2867994 I am still hoping that eventually someone will upvote this answer so that this question doesn't forever remain "unanswered". Given the question, you won't get a better answer.
    – tarsius
    Mar 14, 2018 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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