我如何在新的远程分支上使用 git push?

问题描述 投票:0回答:2

我默认创建了第一个主分支。

我签出一个名为“prd”的新分支,我希望它推送到远程源,但在新分支上。

我试着做:

$ git push -u origin/prd prd

但是控制台记录了:

fatal: 'origin/prd' does not appear to be a git repository
fatal: Could not read from remote repository.

有人可以帮我吗?

git push branch remote-access
2个回答
8
投票
# Create a new branch:
git checkout -b branch_name
# Edit, add and commit your files.
# Push your branch to the remote repository:
git push -u origin branch_name

这应该有效。


6
投票

-u
标志是
-set-upstream
的缩写,它需要一个存储库名称。在这种情况下,存储库有一个别名
origin
。第二个参数是分支的名称。

$ git push origin prd
© www.soinside.com 2019 - 2024. All rights reserved.