Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to another branch with git

Tags:

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
like image 618
robert trudel Avatar asked Jul 13 '17 12:07

robert trudel


3 Answers

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
like image 94
Arpit Solanki Avatar answered Oct 17 '22 02:10

Arpit Solanki


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

Eg : git push origin branch1:branch2

like image 22
Jithish P N Avatar answered Oct 17 '22 01:10

Jithish P N


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)

like image 5
Lorenzo Marcon Avatar answered Oct 17 '22 02:10

Lorenzo Marcon