9

I done a clone of a projet via ssh

git clone ssh ssh://git@10.7.5.11: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
Sajib Khan
  • 20,492
  • 6
  • 56
  • 69
robert trudel
  • 4,469
  • 15
  • 61
  • 104
  • 1
    If you cloned the repository, you already should have that branch locally available. Just create a local branch from it using `git checkout -b dev_ropolo origin/dev_ropolo` and work on that one instead of master. – poke Jul 13 '17 at 12:12
  • Do this: `git push :` – Juanche Jul 13 '17 at 12:14
  • Possible duplicate of [Push commits to another branch](https://stackoverflow.com/questions/13897717/push-commits-to-another-branch) – Liam Jul 13 '17 at 12:24

4 Answers4

13

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
Arpit Solanki
  • 8,903
  • 2
  • 38
  • 57
9
git push <remote> <branch with new changes>:<branch you are pushing to> 

Eg : git push origin branch1:branch2

Liam
  • 25,247
  • 27
  • 110
  • 174
Jithish P N
  • 1,446
  • 3
  • 20
  • 33
5

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)

Lorenzo Marcon
  • 7,921
  • 5
  • 37
  • 61
  • it's the same, you should be able to switch branch. if you still didn't commit your code, use `git stash`, switch to branch dev_ropolo and then `git stash pop`. then add, commit and push. but this is a broader scope respect to the original question – Lorenzo Marcon Jul 13 '17 at 12:38
  • i don't see the change i done in master when i check dev_repolo – robert trudel Jul 13 '17 at 13:06
  • `dev_repolo` is a separate branch. to see the changes you did in master, you should merge it into `dev_repolo`. but really this is another problem, try to solve them one by one. – Lorenzo Marcon Jul 13 '17 at 14:19
-1

to change the branch run:

$ git checkout -b branch_name

to push code to branch run:

$ git push origin remote_branch_name
Liam
  • 25,247
  • 27
  • 110
  • 174