Question

Let's say i have the following graph:

   800      9ff
    v        v
----o--o--o--o--o--o <-master
              \
               o--o--o <-feature

And i want the following state after the command:

   800      9ff
    v        v
----o--o--o--o--o--o <-master
     \
      o--o--o <-feature

So how do i rebase backwards on the same branch? Could you please give an exact answer with the exact branchnames and 3-character-long hashes as specified?

Thank you very much.

Was it helpful?

Solution

This is what rebase --onto is for. While on feature, do this:

git rebase --onto 800 9ff

That moves the branch you're on (feature) onto 800 from 9ff.

OTHER TIPS

I think the following should do what you want.

git checkout 800
git cherry-pick 9ff..feature
git checkout -b newfeature

the resulting graph will look like

   800      9ff
    v        v
----o--o--o--o--o--o <-master
     \        \
      \        o--o--o <-feature
       \              \
        \      (The same commit)
         \           /
          \         /
           \       /
            o--o--o <-newfeature

Deleting the feature branch and renaming the newfeature branch will get you the graph you desire.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top