K.Shikha
K.Shikha

Reputation: 107

Git: Push code to the remote master branch

Created a repository and created a new feature branch. Pushed all my code changes to the feature branch. There is nothing committed to the master branch. I want to push my latest code to the remote master branch. How do I do that?

Upvotes: 2

Views: 12272

Answers (3)

user404
user404

Reputation: 2028

I hope, your remote repository is added to your local repository. Steps to follow:

  1. move to master branch(before that, ensure your feature branch is committed):
    git checkout master
  2. now, update your master branch with the changes made in your feature-branch:
    git merge feature-branch
  3. push changes to remote master:
    git push origin master

Upvotes: 3

dburihabwa
dburihabwa

Reputation: 11

On your machine, switch to the master branch and merge your feature branch on master. Then push your local master branch to the remote master branch.

git checkout master
git merge my-feature-branch
git push origin master

Upvotes: 1

symlink
symlink

Reputation: 12209

You'll probably want to merge the changes to master if you want to push to origin master. As a general rule, your local and origin repo should look similar. Otherwise, if you tried to push to origin master in the future, from your local master or another branch besides feature, you would have to pull and merge anyway.

git checkout master

git merge feature

git push origin master

Upvotes: 2

Related Questions