BanksySan
BanksySan

Reputation: 28560

Pull a commit into another branch exactly (without merging)

I have a structure similar to below:

C1 -- C2  --  C3
               \ -- C4

I want to pull C3 on back on top of C4. (NB: C3 & C3a hold the save files)

C1 -- C2  --  C3
               \ -- C4 -- C3a

If I try to merge or pull I am just told I am already up to date.

How can I force a 're-merge' so that I can get C3 back on top?

Upvotes: 1

Views: 212

Answers (2)

Anshul Goyal
Anshul Goyal

Reputation: 77073

In your current branch, I don't think you can do that since C3 is already merged in the branch.

You can try cherry-picking commits on a new branch though, which should give desired results:

  1. First, create new branch:

    git checkout -b new_branch <C1>
    
  2. Now cherry pick C4 on this new_branch:

    git cherry-pick C4
    
  3. Now cherry pick C# on the new_branch:

    git cherry-pick C3
    

The above should give the desired results in the new_branch:

C1 -- C2  --  C3
  \-- C4  -- C3 

Upvotes: 1

0xAX
0xAX

Reputation: 21837

If I've understand you correctly, you can use git cherry-pick to move your C3 commit on the top of C4

Upvotes: 1

Related Questions