How do I push a local Git branch to master branch in the remote?

这一生的挚爱 提交于 2019-12-02 23:59:33

问题


I have a branch called develop in my local repo, and I want to make sure that when I push it to origin it's merged with the origin/master. Currently, when I push it's added to a remote develop branch.

How can I do this?


回答1:


$ git push origin develop:master

or, more generally

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



回答2:


As people mentioned in the comments you probably don't want to do that... The answer from mipadi is absolutely correct if you know what you're doing.

I would say:

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

 




回答3:


As an extend to @Eugene's answer another version which will work to push code from local repo to master/develop branch .

Switch to branch ‘master’:

$ git checkout master

Merge from local repo to master:

$ git merge --no-ff FEATURE/<branch_Name>

Push to master:

$ git push


来源:https://stackoverflow.com/questions/5423517/how-do-i-push-a-local-git-branch-to-master-branch-in-the-remote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!