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?
$ git push origin develop:master
or, more generally
$ git push <remote> <local branch name>:<remote branch to push into>
git push origin head:master if you don't want to specify the name of the current branch :)
May 29, 2015 at 12:01
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
you can install the git tool https://git-scm.com/downloads and it can help with merging branch to master. I created a branch in RStudio, worked on it, pushed changes to github. Then when I wanted to merge I opened this git GUI tool, navigated to the folder with my repository, then merged the branch to master. I opened RStudio to check if the changes had happened, then pushed to github from RStudio.
You can also do it this way to reference the previous branch implicitly:
git checkout mainline
git pull
git merge -
git push
git init
git add .
git commit -m "Add project to Bitbucket example"
git remote add source https://sample@bitbucket.org/sample/example.git
git push -u -f source master
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
originand then push that to the remote?master- but it's a valid point. If it's stable enough for origin's master branch, then surely it's stable enough for your master branch!master, but Heroku won't run the code unless it's onmasterwithin the app. This is a perfectly reasonable request with legitimate use cases!