curiousengineer
curiousengineer

Reputation: 2625

git pull from local branch to local branch

I have 2 branches BranchA BranchB

To get code from BranchA to BranchB, I do this

- On BranchA - git commit -m "brancha changes"
- On BranchA - git push orign BranchA
- On BranchB - git pull origin BranchA

I want to skip step 2 and commit locally on A and pull in B locally. Sadly, cannot find how?

Upvotes: 0

Views: 573

Answers (2)

Caio Jesus
Caio Jesus

Reputation: 171

  • On BranchA - git commit -m "brancha changes"
  • On BranchB - git merge BranchA

This way you can merge two branches, the code of the BranchB will be up to date with the code of the BranchA.

Upvotes: 1

Polak
Polak

Reputation: 1543

git checkout branch_a
git commit -m "branch_a changes"
git checkout branch_b
git rebase branch_a

Also last command can be replaced by git merge branch_a

If you just want to replace what you have in branch_b by branch_a, last command would be git reset --hard branch_a, that also works for remote branches, git reset --hard origin/branch_a, just make sure you run git fetch origin previously

Upvotes: 3

Related Questions