robert trudel
robert trudel

Reputation: 5779

Push to another branch with git

I done a clone of a projet via ssh

git clone ssh ssh://[email protected]:IMER/ropolo.git

master branch is protected so I can't push my changed.

there is another branch dev_ropolo.

Do I need to bring this branch locally. What is needed to do to be able to push my change to this branch?

Edit:

$ git fetch
* [new branch]      ropolo -> origin/ropolo

$ git branch
* master

Upvotes: 10

Views: 77552

Answers (4)

Jithish P N
Jithish P N

Reputation: 2160

git push <remote> <branch with new changes>:<branch you are pushing to> 

Eg : git push origin branch1:branch2

Upvotes: 14

Eugene Taabazuing
Eugene Taabazuing

Reputation: 1

to change the branch run:

$ git checkout -b branch_name

to push code to branch run:

$ git push origin remote_branch_name

Upvotes: -1

Lorenzo Marcon
Lorenzo Marcon

Reputation: 8179

You said you cloned locally the repository, you can then access the branch dev_ropolo via:

git checkout dev_ropolo

you now have selected dev_ropolo as the current branch: do your local changes, add and commit, and then push them using:

git push origin dev_ropolo

(assuming that the remote is set to origin)

Upvotes: 5

Arpit Solanki
Arpit Solanki

Reputation: 9931

Use fetch command in the local repo

$ git fetch

check that your branch has come to your local using

$ git branch

now change your branch using checkout

$ git checkout -b branch_name

do some changes then

$ git add .
$ git commit -m "message"
$ git push origin remote_branch_name

Upvotes: 14

Related Questions