Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I push my changes to a remote branch

Tags:

git

I am on a master branch 'master' and I have 1 commit ahead I want to create a new remote branch called 'new_remote' and push my commit there?

$ git branch
* master
$ git remote
old_remote

$ git status
# On branch master
# Your branch is ahead of 'old_remote/master' by 1 commit.

I want to push my commit to a new branch on remote called 'new remote' Thank you.

like image 768
michael Avatar asked Jan 15 '11 00:01

michael


People also ask

How do I push a code into a specific branch?

To push to a specific branch in Git, open Git Bash and navigate to the directory from which you want to push files to the remote branch. Then, initialize the directory using the “$ git init” command. Next, run the “$ git add .” command to add all files.


1 Answers

If you are currently working on local branch master, and the new remote branch has not been created yet:

git checkout -b new_branch     // creates a local branch (as a copy of the current)

git push origin new_branch // push it to the remote server
like image 96
karlphillip Avatar answered Oct 01 '22 11:10

karlphillip