Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push to existing remote branch

Tags:

git

git-push

How do I push changes from a local git branch to an existing non-master remote branch? If I do a "git push", it tries to push changes in all local branches to the remotes they are tracking.

like image 564
sandeeps Avatar asked Sep 18 '12 23:09

sandeeps


People also ask

How do I push changes to an existing branch?

In order to push a Git branch to remote, you need to execute the “git push” command and specify the remote as well as the branch name to be pushed. If you are not already on the branch that you want to push, you can execute the “git checkout” command to switch to your branch.

How do I push to an existing remote repository?

The steps to follow in order to push new Git branches to remote repos such as GitHub, GitLab or Bitbucket are as follows: Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch.

How do I push a commit to a remote branch?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.


2 Answers

To do this you use a refspec, as explained in the git push documentation. For example:

git push origin local_branch_name:remote_branch_name
like image 172
Greg Hewgill Avatar answered Oct 16 '22 07:10

Greg Hewgill


If the branch already exists in the repository, it should just be:

git push origin branch_name

like image 30
Kevin Bedell Avatar answered Oct 16 '22 07:10

Kevin Bedell