2

Silly question, but i need help.

There are two branches in the same repository in git-hub. A and B.I have cloned the branch A, i made some changes and now I want to push the changes to branch B.With 'git status' i can see that my branch is up-to-date with 'origin/A'. Should i add and commit the changes and then just 'push' to 'origin/B'?

What can I do to push the changes to the correct branch(B) and not A?I don't want to replace anything in the A branch.

4
  • 2
    I'm slightly confused by your question - are A and B branches or repositories? Commented Oct 9, 2015 at 10:20
  • Sorry.I changed the question.A and B are Branches Commented Oct 9, 2015 at 10:22
  • Did you add your changes to branch A yet or not? Commented Oct 9, 2015 at 10:22
  • I didn't do anything. Commented Oct 9, 2015 at 10:24

3 Answers 3

5

This should work:

  • switch on branch B:

    git checkout B 
  • merge A in B

    git merge A 
  • push the changes

    git push origin B 
Sign up to request clarification or add additional context in comments.

Comments

4

You just need to do git push origin frombranch:tobranch

EDIT after looking at your clarifying comments: git checkout branch-b; git merge branch-a

assuming you have origin\branch-a and is updated.

Comments

0

If A is up to date, and is your origin, checkout branch B and just do git merge origin and B will be updated with all A's latest changes. If you want to check first before merging origin (A), do git fetch origin then do git log -p HEAD..origin to see the changes you are going to merge.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.