Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git move a branch's start forward in the tree

Tags:

git

branch

rebase

Okay I almost have this rebase thing figured out.

I can feel a breakthrough coming - here is the tipping point:

How do I do a rebase to go from:

A - - B - - C - - D - - E (HEAD)
|
\ - - F - - G (branch1)

To:

A - - B - - C - - D - - E (HEAD)
                  |
                  \ - - F - - G (branch1)

I don't just want to merge HEAD~1 into branch1, I think I want to rebase branch1 right?

I feel like I almost grok this - help!?

like image 362
willoller Avatar asked Aug 13 '10 21:08

willoller


People also ask

How do I move current changes to a new branch?

Using the git checkout Command The git checkout -b <BranchName> command will create a new branch and switch to it. Moreover, this command will leave the current branch as it is and bring all uncommitted changes to the new branch.

How do I move a master to another commit?

We can do this by git reset –hard HEAD^ and moving the head pointer by one after one commit, git reset –hard HEAD~n will move the master branch 'n' commits before the recent commit, and git reset –hard <sha1-commit-hash> will directly move the master branch to the desire commit.


2 Answers

This is a standard rebase, there's nothing tricky going on. You want to:

git checkout branch1
git rebase D
like image 165
Michael Mrozek Avatar answered Oct 18 '22 22:10

Michael Mrozek


This can be done with git rebase:

git checkout branch1
git rebase {COMMIT ID of D}
like image 42
Andreas Rehm Avatar answered Oct 18 '22 22:10

Andreas Rehm