如何将本地Git分支推送到远程的主分支?

我在我的本地回购中有一个名为develop的分支,我想确保当我将它推到原点时,它将与origin / master合并。 目前,当我把它添加到远程开发分支。

我怎样才能做到这一点?

 $ git push origin develop:master 

或者更一般地说

 $ git push <remote> <local branch name>:<remote branch to push into> 

正如人们在评论中提到的,你可能不想这么做……如果你知道自己在做什么,那么来自mipadi的回答是绝对正确的。

我会说:

 git checkout master git pull # to update the state to the latest remote master state git merge develop # to bring changes to local master from your develop branch git push origin master # push current HEAD to remote master branch