Simple Simon Simple Simon - 2 months ago 10
Git Question

Git merge with sub branches

I have a master branch with a sub branch (branchA). I have created another sub branch (branchB) from branchA.

If I wish to get the latest changes from branchA into branchB, is it as simple as sitting in branchB and doing?

git merge branchA


or do I need to do a:

git pull origin branchA


What's the difference here? Doesn't pull do an implicit merge? Does

git merge branchName


do an implicit pull on the branchName? Getting confused...

Answer

is it as simple as sitting in branchB and doing:

git merge branchA

Yes, git has power in its simplicity.

or do i need to do a:

git pull origin branchA

What's the difference here?

The only difference here refers to using a remote repository. If you're pushing code to a remote, like Github, from another machine (or working with another person) then you would want to fetch any updates from there. If all changes are just on your local machine, then a pull will provide no new information.

Doesn't pull do an implicit merge?

Yes, it's shorthand for git fetch and then git merge

Does

git merge branchName

do an implicit pull on the branchName?

Nope. Merge only uses your local branch. So, not to confuse you further, but your remotes have local "tracking branches" that you could merge like:

git merge remote/branchName
Comments