2

This is my current GIT state :

0
|\
| \
|  \
|   \
|    1
|    |\
|    | \
|    |  \
|    |   \
|    1    2
|   /     |
|  /      |
| /       |
0         |
|         |
|         |
|         |

The branch 0 is master

The branch 1 is a new feature that has been reviewed, then modified, then merged.

The branch 2 is starting from the branch 1 before it has been reviewed : this means it has the feature, but it is lacking some modifications.

Issue

I would like to incorporate the changes that have been made & merged into my branch 2.

What is the correct command to run, and on which branch ?

EDIT the file that is creating a conflict :

old state :

import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';

export const mockedData ...

new state :

import { Observable } from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/delay';

export const mockedData ...
6
  • Why don't you merge 0 into 2? Commented Apr 12, 2018 at 12:21
  • Because if I do so, it will generate a merge commit, and I don't want that. Is it possible to not do that ? Commented Apr 12, 2018 at 12:22
  • You want to get changes from 0 (after all merges) to 2? Commented Apr 12, 2018 at 12:24
  • Exactly. The modifications are very minimal, like spelling mistakes. Commented Apr 12, 2018 at 12:25
  • Why are you adverse to merge commits? Commented Apr 12, 2018 at 14:53

2 Answers 2

2

Use rebase:

git checkout branch_2
git rebase branch_0
Sign up to request clarification or add additional context in comments.

4 Comments

I tried that, but it gives me a conflict about a file where I added a word : I don't know why, but the file is deleted in my git status. Shouldn't it be just "modified" ?
@trichetriche You should resolve the conflict, and then git rebase --continue, and you'll be fine. I'm not sure what's the state of your files, maybe if you provide more information I can better help you.
That's what I'm saying, resolving the conflict actually deletes my file ... I have updated my question with the states of the file, is that enough ?
Oh it was coming from a windows permission, git deleted the file but it wasn't able to recreate it ! Thank you for your help, I'll manage the permission issue on my own !
0

If you want to incorporate chenges from branch-0 to branch-2, you shlould:

1 - checkout to the branch-0

git checkout 0

2 - rebase that branch to the branch-2

git rebase 2

3 - solve your conflicts and stage your changes

git add *

4 - continue your rebase

git rebase --continue

Comments

Your Answer

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