Point branch to new commit

Git

Git Problem Overview


(This question is the opposite of this one)

How can I go from this

dev            C - D
             /
master A - B 

to this?

dev                D
                 /
master A - B - C 

I know I'm going to kick myself when I see the answer, but for the moment I'm a bit stuck...

Git Solutions


Solution 1 - Git

Solution
git checkout master
git merge C

With C being the SHA1 of commit C.

Result
                 D (dev)
                /
master A - B - C (move master HEAD)

It should be a fast-forward merge.

Solution 2 - Git

Necromancy, I know.

git branch -f master C

Will not touch current working tree at all - you can have your work in progress.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBenjolView Question on Stackoverflow
Solution 1 - GitVonCView Answer on Stackoverflow
Solution 2 - GitaragaerView Answer on Stackoverflow