简体   繁体   中英

from a remote branch to a local branch : git issue

I am on a repo on github. I have one local branch called : master and on the remote repo there are two branches, branch1 and branch2. I cloned the repo from the branch1. But then, I wanted to pull branch2, which is quite different from branch1, into master. So I did : git pull origin master:branche2

But when I run a git diff command between master and the new local branch2, I have no differences. Does this mean that there was no merging, and that the former master has been totally replaced by the imported branch2 ?

Do the following:

git branch branch2
git checkout branch2
git pull origin branch2
git checkout master
git merge branch2

In git if you need to change from one branch to another the you need to do:

git checkout branch_name

example: Just change to the branch you want as a base:

example: git checkout branch1

if you are on branch1 and want to merge branch2 on to branch1 then:

git merge origin/branch2

Now you have the differences on branch2 merged on to branch1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM