Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point branch to new commit

Tags:

git

(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...

like image 557
Benjol Avatar asked Aug 16 '10 11:08

Benjol


People also ask

Which command can make your current branch point to another commit without changing the working tree?

git branch -f <branchname> <commit>


2 Answers

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.

like image 152
VonC Avatar answered Sep 22 '22 19:09

VonC


Necromancy, I know.

git branch -f master C 

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

like image 39
aragaer Avatar answered Sep 24 '22 19:09

aragaer