How to merge github master with the branch I checked out from the company's git?
漂亮男人
漂亮男人 2017-05-02 09:44:44
0
3
721

Built a project on the company's git server, then create a branch b1
Then add a github master
git remote add r1 https://github.com/xx/xx

How to merge the local branch b1 and the remote r1 branch?

Additional edit, the original requirement is to do secondary development on an active project on github, and also put the code on the company git. Do you have any good suggestions? Thank you

漂亮男人
漂亮男人

reply all(3)
仅有的幸福

If you want to merge two branches, you must at least ensure that they have the same ancestor. According to the original poster, they do have the same ancestor, so they can be merged.
In this case, my plan is to first use the git clone命令克隆的本地,然后使用git remote add ...命令添加公司git服务器上的仓库为远程仓库;接着在本地使用git pull命令进行拉取与合并,当然git pullcommand for the project in the github warehouse and then add the url alias and branch name of the remote branch; finally, if the conflict is resolved and the merge is completed, it can be pushed to the company's remote warehouse.
I think it might be safer to merge in another local warehouse like this. Of course, because I have never actually dealt with such a problem, if my solution does not succeed, I hope the poster can give me feedback on what the problem is.

Ty80

git push You can choose which remote server to use, so first pull the branch from github, resolve the conflict, and then push it to the master of the company branch, and wait for people from the company to check the merge. There should be no problem

为情所困

According to the questioner, r1 is actually not a branch, but a remote. Let's first assume that you want to merge the local b1 branch and the master branch of r1.

Now that you have added r1, all you need to do is:

  1. First switch to b1. The command is git checkout b1

  2. Get the HEAD pointer of r1 master branch. The command is git fetch r1

  3. Apply the content on r1 master branch to local. Available git merge r1/master,也可以 git rebase r1/master. The former generates non-linear history records, and the latter generates linear ones.

Then you push it to the company’s library and you’re done

By the way:
git pull = git fetch + git mergegit pull = git fetch + git merge
git pull --rebase = git fetch + git rebasegit pull --rebase = git fetch + git rebase

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template