Arunoda Susiripala
Arunoda Susiripala

Reputation: 2536

Which branch to select for rebasing

I've two simple branches named master and admin. History is shown below.

History

I simply want to take admin branch's updates to master without merge commits. Then I have two options. Which of the following should I need to follow?

1.Checkout to admin and git rebase master and fast-forward merge admin into master

2.Checkout to master and git rebase admin

EDIT:

I found some other findings too (that may be a reason to choose a solution)

  1. With option 1 it will remain master commits' SHA1 IDS without changing and change admin's SHA IDS
  2. With option 2 it will do the opposite of above

So I think this is the main reason why we need to choose option 1, since we should not change the master's commits.

Upvotes: 0

Views: 145

Answers (3)

Adam Dymitruk
Adam Dymitruk

Reputation: 129546

either way will work, but master branch is usually what others are working against as well if you are working with others. So from the admin branch, rebase it onto master:

git rebase master

Upvotes: 1

knittl
knittl

Reputation: 265201

The resulting history (oldest commit on top) for both cases:

  1. Checkout to admin and git rebase master and fast-forward merge admin into master

    added index file
    updated index
    admin added
    admin updated
    
  2. Checkout to master and git rebase admin

    added index file
    admin added
    admin updated
    updated index
    

So, I think you want to use option 1

Upvotes: 0

jbowes
jbowes

Reputation: 4150

You want to do option 1. that will apply everything new that's in admin on top of the current state of master

Upvotes: 1

Related Questions