我有两个分支,即master和开发在一个GitHub库。我正在做我所有的开发在开发分支显示。

git branch development
git add *
git commit -m "My initial commit message"
git push -u origin development

现在我想将开发分支上的所有更改合并到主分支中。我目前的方法是:

git checkout master 
git merge development
git push -u origin master 

请让我知道我所遵循的程序是否正确。


当前回答

1. //pull the latest changes of current development branch if any        
git pull (current development branch)

2. //switch to master branch
git checkout master 

3. //pull all the changes if any
git pull

4. //Now merge development into master    
git merge development

5. //push the master branch
git push origin master

其他回答

我认为最简单的解决办法是

git checkout master
git remote update
git merge origin/Develop -X theirs
git commit -m commit -m "New release"
git push --recurse-submodules=check --progress "origin" refs/heads/Master

这也保存了所有正在使用的分支的历史

我通常都是这么做的。首先,确保您已经准备好将更改合并到master中。

通过git获取,检查开发是否与远程服务器的最新更改保持一致 一旦获取完成,git签出主。 通过执行git pull,确保主分支有最新的更新 一旦准备工作完成,就可以开始使用git合并开发进行合并了 用git Push -u origin master进行修改,就完成了。

您可以在本文中找到更多关于git合并的信息。

1)在分支开发上,使用以下命令检查git状态:

git status

不应该有未提交的代码。如果是,将你的代码推到开发分支:

git add *

git commit -m "My initial commit message"

git push origin Development

2)在Development分支中,运行以下两条命令:

git branch -f master HEAD

git push -f origin master

它将把您的开发分支代码推到主分支。

1. //push the latest changes of current development branch if any        
git push (current development branch)

2. //switch to master branch
git checkout master 

3. //pull all the changes if any from (current development branch)
git pull origin (current development branch)

4. //Now merge development into master    
git merge development

5. //push the master branch
git push origin master

Error
To https://github.com/rajputankit22/todos-posts.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/rajputankit22/todos-posts.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Then Use 
5. //push the master branch forcefully
git push -f origin master

一旦你“签出”了开发分支,你……

 git add .
 git commit -m "first commit"
 git push origin dev
 git merge master

 git checkout master 
 git merge dev
 git push origin master