Pus
Pus

Reputation: 799

Git pull the chanes from another branch into current branch

I have four branches:

  1. Master,
  2. Branch 1
  3. Branch 2
  4. Branch 3

Dev 1 is working into Branch 1, Dev 2 is working in Branch 2, and Dev 3 is working in Branch 3.

Now I need to pull the changes of Branch 1 into Branch 3, not merge. So that in future Dev 1 continue to work on Branch 1 and Dev 3 has all codes from Dev 1 as well as Branch 3.

How can we do this?

Upvotes: 0

Views: 443

Answers (3)

Ahmad
Ahmad

Reputation: 1931

That is probably a bad thing to do. I would personally merge in from the branch I want changes from. From my understanding you’re looking for cherry-pick:

git cherry-pick commit

Upvotes: 0

matt
matt

Reputation: 535988

Now I need to pull the changes of Branch 1 into Branch 3, not merge. So that in future Dev 1 continue to work on Branch 1 and Dev 3 has all codes from Dev 1 as well as Branch 3

You can't. Changes in one branch do not magically percolate live into another branch.

You can make it so that branch 3 acquires all the "changes" that are in branch 1 now. That is what a merge is, or a rebase. But you can not make it so that future changes in branch 1 somehow pass thru a wormhole and simply appear in branch 3 on dev 3's machine. The only way to make that happen is for dev 3 to acquire the "changes" from branch 1 again.

And that is not an unreasonable thing to do. When I'm working on a feature, I pull develop and rebase my branch onto it, every hour or so. So that way, I always have the latest "changes" from develop. But not because of magic. Because of me.

Upvotes: 0

Durgesh Pal
Durgesh Pal

Reputation: 695

You can take pull of Branch 1 in Branch 3 then all changes form Branch 1 will be in Branch 3

git checkout Branch 3
git pull origin Branch 1

Upvotes: 1

Related Questions