git 将开发分支合并到主分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36570193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:05:30  来源:igfitidea点击:

Merging develop branch into master

gitmerge

提问by meez

I have a local repo with 2 branches masterand develop.

我有一个带有 2 个分支masterdevelop.

  • in developbranch I have all my Drupal 8 core code
  • in my masterbranch I have 1 commit (Initial commit)
  • develop分支中我有我所有的 Drupal 8 核心代码
  • 在我的master分支中,我有 1 个提交(初始提交)

On my remote repo I have all my Drupal 8 core code in branch develop. How do I get this code in the remote master branch? How do I have to merge those repo's?

在我的远程仓库中,我的所有 Drupal 8 核心代码都在 branch 中develop。如何在远程主分支中获取此代码?我该如何合并这些回购?

Update:

更新:

When I do git statusI get:

当我这样做时git status

On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    griffioenrotterdam.sublime-project
    griffioenrotterdam.sublime-workspace
    sites/

nothing added to commit but untracked files present (use "git add" to track)

What do I have to do?

我需要做什么?

Update 2:

更新 2:

When I do git checkout developI get:

当我这样做时git checkout develop

error: The following untracked working tree files would be overwritten by checkout:
    sites/default/default.services.yml
    sites/default/default.settings.php
Please move or remove them before you can switch branches.
Aborting

What do I have to do?

我需要做什么?

回答by ItayB

Summary: you need to switch to your develop branch, pull the code from the remote repo, then merge it into master (locally) and push it back to remote repo (into master branch)

总结:你需要切换到你的开发分支,从远程仓库拉取代码,然后将其合并到master(本地)并推送回远程仓库(到master分支)

git checkout develop
git pull origin develop
git checkout master
git merge develop
git push origin master

回答by Francesco

Merge locally develop into master and then push

合并本地开发成master然后push

git checkout master
git merge develop
git push

回答by Arun Prasad

First commit your changes to master

首先将更改提交给 master

 git checkout develop
 git pull origin develop
 git checkout master
 git merge develop
 git push origin master