简体   繁体   English

Git:将分支合并到Master中

[英]Git: Pulling and merging branch into Master

So far I have used Git individually and first time I am using as a team. 到目前为止,我已经单独使用过Git,并且第一次是作为团队使用。 I am facing an issue: There is a master repo which contains 2 branches; 我面临一个问题:有一个master库,其中包含2个分支。 dev1 and dev2 . dev1dev2 I have been assigned to review Code of dev1 and merge into master . 我已被分配去审查dev1代码并合并到master

Now In order to view code or running it I want to set his branch on local machine. 现在,为了查看或运行代码,我想在本地计算机上设置他的分支。 How do I pull all of his branch data very first time so that I could have his folders on machine and how later I could pull his changes from his branch. 我如何第一次提取他的所有分支数据,以便将他的文件夹放在机器上,以及以后如何从他的分支中提取他的更改。

Later how do I merge branch dev1 into master ? 以后如何将分支dev1合并到master

Thanks 谢谢

If you not already have a clone of the remote repo: 如果您还没有远程仓库的克隆:

git clone <remote repo url from GitHub>
cd <repo>

Fetch all remote branches from remote repo: 从远程仓库中获取所有远程分支:

git fetch origin

Checkout remote branch 'dev1': 检出远程分支“ dev1”:

git checkout dev1

Review and run the code as you see fit. 查看并运行您认为合适的代码。

If you have privileges (on GitHub) to push to 'origin:master' you should be able to merge 'master' with 'dev1' and push the updated 'master': 如果您有特权(在GitHub上)可以推送到“ origin:master”,则应该能够将“ master”与“ dev1”合并并推送更新的“ master”:

git checkout master
git merge dev1
git push origin master

If you do not have privileges to update remote 'origin:master' you can issue a pull-request (on GitHub). 如果您没有权限更新远程“ origin:master”,则可以发出拉取请求(在GitHub上)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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