使用 git 推送到另一个分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45080223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:49:20  来源:igfitidea点击:

Push to another branch with git

git

提问by robert trudel

I done a clone of a projet via ssh

我通过 ssh 克隆了一个项目

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

masterbranch is protected so I can't push my changed.

master分支受到保护,所以我不能推送我的更改。

there is another branch dev_ropolo.

还有另一个分支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

回答by Arpit Solanki

Use fetch command in the local repo

在本地 repo 中使用 fetch 命令

$ 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

回答by Lorenzo Marcon

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

你说你在本地克隆了存储库,然后你可以dev_ropolo通过以下方式访问分支:

git checkout dev_ropolo

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

您现在已选择dev_ropolo作为当前分支:进行本地更改、添加和提交,然后使用以下命令推送它们:

git push origin dev_ropolo

(assuming that the remote is set to origin)

(假设遥控器设置为origin

回答by Jithish P N

git push :

git推:

Eg : git push origin branch1:branch2

例如:git push origin branch1:branch2