10

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 
3
  • 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. Commented Jul 13, 2017 at 12:12
  • 1
    Do this: git push <remote> <source branch>:<dev_ropolo> Commented Jul 13, 2017 at 12:14
  • 1
    Possible duplicate of Push commits to another branch Commented Jul 13, 2017 at 12:24

4 Answers 4

14

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 
Sign up to request clarification or add additional context in comments.

Comments

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

Eg : git push origin branch1:branch2

1 Comment

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)

3 Comments

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
i don't see the change i done in master when i check dev_repolo
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.
-1

to change the branch run:

$ git checkout -b branch_name 

to push code to branch run:

$ git push origin remote_branch_name 

1 Comment

If you change the branch it's no longer another branch...?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.