如何创建远程 Git 分支?

发布于 2024-08-06 10:49:05 字数 146 浏览 5 评论 0 原文

我创建了一个本地分支机构。如何将其推送到远程服务器?

更新:我在此处为 Git 2.0 编写了一个更简单的答案

I created a local branch. How do I push it to the remote server?

UPDATE: I have written a simpler answer for Git 2.0 here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(26

南烟 2024-08-13 10:49:05

首先,创建一个新的本地分支并检查它:

git checkout -b <branch-name>

当您将其推送到远程服务器时,会自动创建远程分支:

git push <remote-name> <branch-name> 

通常是 origin ,这是 git 为您克隆的远程服务器提供的名称。然后,您的同事可以简单地拉动该分支。

但请注意,形式上,格式为:

git push <remote-name> <local-branch-name>:<remote-branch-name>

但是当您省略一个时,它假定两个分支名称相同。话虽如此,作为警告的话,不要犯仅指定 : (使用冒号)的严重错误,或者远程分支将被删除!


为了让后续的 git pull 知道要做什么,您可能想使用:

git push --set-upstream <remote-name> <local-branch-name> 

如下所述,--set-upstream 选项设置上游分支:

对于每个最新的分支或
推送成功,添加上游
(跟踪)参考,使用者
无参数 git-pull(1) 和其他
命令。

First, create a new local branch and check it out:

git checkout -b <branch-name>

The remote branch is automatically created when you push it to the remote server:

git push <remote-name> <branch-name> 

<remote-name> is typically origin, which is the name which git gives to the remote you cloned from. Your colleagues may then simply pull that branch.

Note however that formally, the format is:

git push <remote-name> <local-branch-name>:<remote-branch-name>

But when you omit one, it assumes both branch names are the same. Having said this, as a word of caution, do not make the critical mistake of specifying only :<remote-branch-name> (with the colon), or the remote branch will be deleted!


So that a subsequent git pull will know what to do, you might instead want to use:

git push --set-upstream <remote-name> <local-branch-name> 

As described below, the --set-upstream option sets up an upstream branch:

For every branch that is up to date or
successfully pushed, add upstream
(tracking) reference, used by
argument-less git-pull(1) and other
commands.

白馒头 2024-08-13 10:49:05

首先,您必须在本地创建分支

git checkout -b your_branch

之后,您可以在您的分支本地工作,当您准备好共享分支时,推送它。下一个命令将分支推送到远程存储库源并跟踪它

git push -u origin your_branch

队友可以通过执行以下操作到达您的分支:

git fetch
git checkout origin/your_branch

您可以继续在分支中工作并在需要时随时推送,而无需将参数传递给 git push (无参数 git Push 会将 master 推送到远程 master、本地 your_branch 到远程 your_branch 等...)

git push

队友可以通过执行提交然后显式推送来推送到您的分支,

# ... work ...
git commit
# ... work ...
git commit
git push origin HEAD:refs/heads/your_branch

或者跟踪分支以避免 git Push 的参数

git checkout --track -b your_branch origin/your_branch
# ... work ...
git commit
# ... work ...
git commit
git push

First, you must create your branch locally

git checkout -b your_branch

After that, you can work locally in your branch, when you are ready to share the branch, push it. The next command push the branch to the remote repository origin and tracks it

git push -u origin your_branch

Teammates can reach your branch, by doing:

git fetch
git checkout origin/your_branch

You can continue working in the branch and pushing whenever you want without passing arguments to git push (argumentless git push will push the master to remote master, your_branch local to remote your_branch, etc...)

git push

Teammates can push to your branch by doing commits and then push explicitly

# ... work ...
git commit
# ... work ...
git commit
git push origin HEAD:refs/heads/your_branch

Or tracking the branch to avoid the arguments to git push

git checkout --track -b your_branch origin/your_branch
# ... work ...
git commit
# ... work ...
git commit
git push
我不是你的备胎 2024-08-13 10:49:05

简单的 Git 2.0+ 解决方案:

Git 2.0 开始,行为变得更加简单

您可以使用 push.default = current 配置 git 来使生活更轻松:

我添加了这个,所以现在我可以使用 -u 将新分支推送到上游,

$ git push -u

将跟踪同名的远程分支。现在通过此配置,您将自动猜测对 git Push 的远程引用。来自 git.config 文档

push.default

定义在没有明确给出 refspec 的情况下 git push 应采取的操作。

push.default = current - 推送当前分支以更新分支
接收端同名。适用于中央和非中央工作流程。

对我来说,这很好地简化了我的日常 Git 工作流程。配置设置负责“通常”的用例,即您在本地添加分支并希望远程创建它。此外,我只需执行 git co remote_branch_name 即可轻松地从远程创建本地分支(而不是使用 --set-upstream-to 标志)。

我知道这个问题和接受的答案相当旧,但行为已经改变,因此现在存在配置选项以使您的工作流程更简单。

要添加到全局 Git 配置,请在命令行上运行:

$ git config --global push.default current

Simple Git 2.0+ solution:

As of Git 2.0, the behavior has become simpler:

You can configure git with push.default = current to make life easier:

I added this so now I can just push a new branch upstream with

$ git push -u

-u will track remote branch of the same name. Now with this configuration, you will auto-guess the remote reference to git push. From git.config documentation:

push.default

Defines the action git push should take if no refspec is explicitly given.

push.default = current - push the current branch to update a branch with the
same name on the receiving end. Works in both central and non-central workflows.

For me, this is a good simplification of my day-to-day Git workflow. The configuration setting takes care of the 'usual' use case where you add a branch locally and want to create it remotely. Also, I can just as easily create local branches from remotes by just doing git co remote_branch_name (as opposed to using --set-upstream-to flag).

I know this question and the accepted answers are rather old, but the behavior has changed so that now configuration options exist to make your workflow simpler.

To add to your global Git configuration, run this on the command line:

$ git config --global push.default current
一笔一画续写前缘 2024-08-13 10:49:05

正如前面的答案中所述,

git push <remote-name> <local-branch-name>:<remote-branch-name>

足以推动本地分支机构。

您的同事可以使用以下命令拉取所有远程分支(包括新分支):

git remote update

然后,要在分支上进行更改,通常的流程:

git checkout -b <local-branch-name> <remote-name>/<remote-branch-name>

As stated in the previous answers,

git push <remote-name> <local-branch-name>:<remote-branch-name>

is enough for pushing a local branch.

Your colleagues, can pull all remote branches (including new ones) with this command:

git remote update

Then, to make changes on the branch, the usual flow:

git checkout -b <local-branch-name> <remote-name>/<remote-branch-name>
又爬满兰若 2024-08-13 10:49:05

基于当前分支在本地创建新分支:

git checkout -b newbranch

像平常一样提交任何更改。然后,将其推送到上游:

git push -u origin HEAD

这是将当前分支推送到 origin 上同名分支并跟踪它的快捷方式,这样您就不需要指定 origin HEAD 将来。

Create a new branch locally based on the current branch:

git checkout -b newbranch

Commit any changes as you normally would. Then, push it upstream:

git push -u origin HEAD

This is a shortcut to push the current branch to a branch of the same name on origin and track it so that you don't need to specify origin HEAD in the future.

始于初秋 2024-08-13 10:49:05

如果您想从当前分支创建分支,或者

git checkout -b {your_local_branch_name}

想要从远程分支创建分支,则可以尝试

git checkout -b {your_local_branch_name} origin/<remote_branch_name>

如果完成更改,则可以添加文件。

git add -A or git add <each_file_names>

然后在本地进行提交

git commit -m 'your commit message'

当你想推送到远程仓库时

git push -u origin <your_local_branch_name>

全部一起将是

git checkout -b bug_fixes 


如果您想从远程分支创建本地分支 bug_fixes,请说 development

git checkout -b bug_fixes origin/development

您可以通过以下方式将分支推送到远程仓库:

git push -u origin bug_fixes

任何时候您想从任何其他分支更新您的分支分支说master

git pull origin master

If you want to create a branch from the current branch

git checkout -b {your_local_branch_name}

you want a branch from a remote branch, you can try

git checkout -b {your_local_branch_name} origin/<remote_branch_name>

If you are done with changes you can add the file.

git add -A or git add <each_file_names>

Then do a commit locally

git commit -m 'your commit message'

When you want to push to remote repo

git push -u origin <your_local_branch_name>

All together will be

git checkout -b bug_fixes 

or
If you want to create a local branch bug_fixes from a remote branch, say development

git checkout -b bug_fixes origin/development

You can push to the branch to remote repo by

git push -u origin bug_fixes

Anytime you want to update your branch from any other branch say master,

git pull origin master
乞讨 2024-08-13 10:49:05

[快速解答]

您可以分两步完成:

1.使用checkout创建本地分支:

git checkout -b yourBranchName

2.使用 >push 命令自动创建分支并将代码发送到远程存储库:

git push -u origin yourBranchName

有多种方法可以做到这一点,但我认为这种方法非常简单。

[Quick Answer]

You can do it in 2 steps:

1. Use the checkout for create the local branch:

git checkout -b yourBranchName

2. Use the push command to autocreate the branch and send the code to the remote repository:

git push -u origin yourBranchName

There are multiple ways to do this but I think that this way is really simple.

天涯沦落人 2024-08-13 10:49:05

如果你实际上只想创建远程分支而没有本地分支,你可以这样做:

git push origin HEAD:refs/heads/foo

它将你的 HEAD 中的任何内容推送到远程上不存在的分支 foo

If you wanna actually just create remote branch without having the local one, you can do it like this:

git push origin HEAD:refs/heads/foo

It pushes whatever is your HEAD to branch foo that did not exist on the remote.

无妨# 2024-08-13 10:49:05

最简单的解决方案... Drumm Roll... git version 2.10.1 (Apple Git-78)

1) git checkout -b localBranchNameThatDoesNotExistInRemote

2) Do your changes, and do a git commit 

3) git push origin localBranchNameThatDoesNotExistInRemote --force

注意 - 您刚刚在本地环境中创建的分支,以及您所在的远程不存在的分支尝试推送时,必须具有相同的名称

Easiest Solution... Drumm Roll... git version 2.10.1 (Apple Git-78)

1) git checkout -b localBranchNameThatDoesNotExistInRemote

2) Do your changes, and do a git commit 

3) git push origin localBranchNameThatDoesNotExistInRemote --force

N.B. - The branch you just created in your local environment, and the remote non-existing branch where you are trying to push, must have the same name.

瞳孔里扚悲伤 2024-08-13 10:49:05

首先,您在本地创建分支:

git checkout -b your_branch

然后远程创建分支:

git push --set-upstream origin your_branch

注意:这适用于最新版本的 git:

$ git --version
git version 2.3.0

干杯!

First you create the branch locally:

git checkout -b your_branch

And then to create the branch remotely:

git push --set-upstream origin your_branch

Note: This works on the latests versions of git:

$ git --version
git version 2.3.0

Cheers!

黒涩兲箜 2024-08-13 10:49:05

你可以简单地,

  1. git checkout -b YOUR-NEW-BRANCH-NAME
  2. git add .
  3. git push origin YOUR-NEW-BRANCH-NAME

你可以在相关 git repo 下看到您的分支以及代码

干杯! :)

you can simply,

  1. git checkout -b YOUR-NEW-BRANCH-NAME
  2. git add .
  3. git push origin YOUR-NEW-BRANCH-NAME

you can see your branch with the code under the relevant git repo

Cheers !! :)

时间海 2024-08-13 10:49:05

在本地计算机上创建分支并在此分支中切换:

$ git checkout -b [name_of_your_new_branch]

在 github 上推送分支:

$ git push origin [name_of_your_new_branch]

当您想在分支中提交某些内容时,请确保在您的分支中。

您可以查看使用以下命令创建的所有分支:

$ git branch

它将显示:

* approval_messages
  master
  master_clean

为您的分支添加新的远程:

$ git remote add [name_of_your_remote] 

将更改从您的提交推送到您的分支:

$ git push origin [name_of_your_remote]

当官方存储库中的原始分支已更新时更新您的分支:

$ git fetch [name_of_your_remote]

然后您需要申请合并更改,如果您的分支源自开发,您需要执行以下操作:

$ git merge [name_of_your_remote]/develop

删除本地文件系统上的分支:

$ git branch -d [name_of_your_new_branch]

强制删除文件系统上的本地分支:

$ git branch -D [name_of_your_new_branch]

删除 github 上的分支:

$ git push origin :[name_of_your_new_branch]

此处所有信息

其他现有项目

Create the branch on your local machine and switch in this branch :

$ git checkout -b [name_of_your_new_branch]

Push the branch on github :

$ git push origin [name_of_your_new_branch]

When you want to commit something in your branch, be sure to be in your branch.

You can see all branches created by using :

$ git branch

Which will show :

* approval_messages
  master
  master_clean

Add a new remote for your branch :

$ git remote add [name_of_your_remote] 

Push changes from your commit into your branch :

$ git push origin [name_of_your_remote]

Update your branch when the original branch from official repository has been updated :

$ git fetch [name_of_your_remote]

Then you need to apply to merge changes, if your branch is derivated from develop you need to do :

$ git merge [name_of_your_remote]/develop

Delete a branch on your local filesystem :

$ git branch -d [name_of_your_new_branch]

To force the deletion of local branch on your filesystem :

$ git branch -D [name_of_your_new_branch]

Delete the branch on github :

$ git push origin :[name_of_your_new_branch]

Here All Information

Other Existing project

帅气称霸 2024-08-13 10:49:05

从现有分支创建本地分支(可以是 master/develop/any-other-branch)。

git checkout -b 分支名称

将其推送到远程

git push -u 远程名称本地分支名称:远程分支名称

这里,

  1. -u :设置上游分支
  2. remote_name :git 在创建存储库时默认将名称设置为“origin”。但是,可以将其更改为不同的任意名称。
  3. local_branch_name :是要推送的本地分支的名称。
  4. remote_branch_name :是我们要在远程创建的远程分支的名称。

如果我们删除本地和远程分支名称,它将具有以下格式

git push -u 远程名称分支名称

这会将本地分支推送到远程,并与本地分支branch_name同名。本地分支也将跟踪远程分支。

Creating a local branch from an existing branch (can be master/ develop/ any-other-branch).

git checkout -b branch_name

Push this to remote

git push -u remote_name local_branch_name:remote_branch_name

Here,

  1. -u : sets the upstream branch
  2. remote_name : git sets the name by default to be "origin" when it creates the repository. This can however be changed to a different arbitrary name.
  3. local_branch_name : is the name of the local branch to be pushed.
  4. remote_branch_name : is the name of the remote branch that we want to be created on remote.

If we remove the local and remote branch names, it will have the format

git push -u remote_name branch_name

This will push the local branch to remote and with the same name as the local branch branch_name. The local branch will be tracking the remote branch as well.

旧伤慢歌 2024-08-13 10:49:05

我知道这个问题得到了很好的回答,但只是想列出我创建新分支“myNewBranch”并推送到远程(在我的情况下为“origin”)并设置跟踪所采取的步骤。将此视为“TL;DR”版本:)

# create new branch and checkout that branch
git checkout -b myNewBranch
# now push branch to remote 
git push origin myNewBranch
# set up the new branch to track remote branch from origin
git branch --set-upstream-to=origin/myNewBranch myNewBranch

I know this question is well answered, but just wanted to list the steps I take to create a new branch "myNewBranch" and push to remote ("origin" in my case) and set up tracking. Consider this the "TL;DR" version :)

# create new branch and checkout that branch
git checkout -b myNewBranch
# now push branch to remote 
git push origin myNewBranch
# set up the new branch to track remote branch from origin
git branch --set-upstream-to=origin/myNewBranch myNewBranch
沧笙踏歌 2024-08-13 10:49:05

只是想添加 while:

git checkout -b {branchName}

创建一个新分支,它还会检查该分支/使其成为您当前的分支。如果出于某种原因,您想要做的只是折断一个分支,但不将其设为当前分支,那么您将使用以下命令:

git branch {branchName}

在第一个命令中,“checkout”使该分支成为您的当前分支,而“ -b”的意思是:这个分支还不存在,所以为我做一个。

Just wanted to add that while:

git checkout -b {branchName}

Creates a new branch, it also checks out that branch / makes it your current branch. If, for some reason, all you want to do is snap off a branch but not make it your current branch, then you would use the following command:

git branch {branchName}

In the first command, "checkout" makes said branch your current branch, and the "-b" means: this branch doesn't exist yet, so make it for me.

他不在意 2024-08-13 10:49:05

现在使用 git,当您位于正确的分支时,您只需键入

git push --set-upstream origin >;

并 git 为您创建原始分支。

Now with git, you can just type, when you are in the correct branch

git push --set-upstream origin <remote-branch-name>

and git create for you the origin branch.

静谧幽蓝 2024-08-13 10:49:05

如何通过源码树来做

 1: Open SourceTree, click on Repository -> Checkout
 2: Click on Create New Branch
 3: Select the branch where you want to get code for new branch 
 4: Give your branch name
 5: Push the branch  (by click on Push-button)

How to do through Source Tree

 1: Open SourceTree, click on Repository -> Checkout
 2: Click on Create New Branch
 3: Select the branch where you want to get code for new branch 
 4: Give your branch name
 5: Push the branch  (by click on Push-button)
ゃ人海孤独症 2024-08-13 10:49:05

git push -u <远程名称>如果新创建的分支不是从同一个存储库生成的,即如果您尚未使用 git checkout -b new_branch 创建新分支,则 不起作用>,那么这将不起作用。

例如,我在本地克隆了两个不同的存储库,我必须将 repo2/branch1 复制到 repo1/,然后也推送它。

链接帮助了我将我的本地分支(从另一个存储库克隆)推送到我的远程存储库:

git push -u <remote-name> <branch-name> doesn't work if the newly created branch isn't spawned from the same repo, i.e. if you haven't created the new branch using git checkout -b new_branch, then this will not work.

For eg, I had cloned two different repositories locally and I had to copy repo2/branch1 to repo1/ and then push it too.

This link helped me push my local branch (cloned from another repo) to my remote repo:

和影子一齐双人舞 2024-08-13 10:49:05

从 Git 2.37.0 开始,您不再需要“--set-upstream origin”。只需git推送。您可以通过启用 push.autoSetupRemote 选项来实现此目的

git config --global --add --bool push.autoSetupRemote true

Starting from Git 2.37.0, you do not need "--set-upstream origin" anymore. Just git push. You can achieve this with the push.autoSetupRemote option enabled

git config --global --add --bool push.autoSetupRemote true

攒一口袋星星 2024-08-13 10:49:05

要在远程创建新分支,可以使用以下命令:

git checkout -b

例如,要创建一个名为“feature_branch”的新分支,您可以使用以下命令:

git checkout -b feature_branch

这将在本地创建一个新分支,但不会将其推送到远程存储库。要将新分支推送到远程存储库,可以使用以下命令:

git push origin feature_branch

例如,要将“feature_branch”分支推送到远程存储库,可以使用以下命令:

git push origin feature_branch

这会将新分支推送到远程存储库,并且其他用户可以使用它。

以下是有关在远程创建新分支时需要记住的一些其他事项:

您可以使用 gitbranch -l 命令列出本地存储库中的所有分支。

您可以使用 git checkout 命令切换到不同的分支。

您可以使用 git merge 命令将分支合并到当前分支。

可以使用 git reset --hard 命令将当前分支重置为指定分支的状态。

To create a new branch in remote, you can use the following command:

git checkout -b <new-branch-name>

For example, to create a new branch called "feature_branch", you would use the following command:

git checkout -b feature_branch

This will create a new branch locally, but it will not push it to the remote repository. To push the new branch to the remote repository, you can use the following command:

git push origin feature_branch

For example, to push the "feature_branch" branch to the remote repository, you would use the following command:

git push origin feature_branch

This will push the new branch to the remote repository, and it will be available to other users.

Here are some additional things to keep in mind about creating new branches in remote:

You can use the git branch -l command to list all of the branches in your local repository.

You can use the git checkout command to switch to a different branch.

You can use the git merge command to merge a branch into the current branch.

You can use the git reset --hard command to reset the current branch to the state of the specified branch.

撩心不撩汉 2024-08-13 10:49:05

以下是在 Eclipse 中通过 Egit 执行此操作的方法。

  1. 进入“Git Repository Exploring”视图并展开您想要创建分支的 git 项目。在分支下 ->本地..选择要为其创建分支的分支(在我的例子中,我选择了master..如果您愿意,您可以选择另一个分支)..然后右键单击并单击“创建分支”选项..并选择结帐此项目选项,然后单击完成按钮。

  2. 现在从项目资源管理器中选择项目..右键单击然后团队 ->推送分支。

将创建一个新的远程分支。您可以将分支的名称提供给您的同事,以便他们可以拉取它。

Here is how you do it in eclipse through Egit.

  1. Go the "Git Repository Exploring" view and expand the git project to which you want to create a branch. Under Branches -> Local .. select the branch for which you want to create the branch ( In my case I selected master .. you can select another branch if you wish) .. then right click and click on Create Branch option .. and select the checkout this project option and then click the finish button.

  2. Now from the project explorer select the project .. right click then Team -> Push Branch.

A new remote branch will be created. You can give the name of the branch to your colleagues so that they can pull it.

慵挽 2024-08-13 10:49:05

我使用了两种方法来创建分支

如果您使用 TortoiseGit 请按照以下步骤操作:-

1.使用 TortoiseGit 创建分支

<块引用>

右键单击您的项目>>> TortoiseGit >>>创建分支>>写下分支的名称并选择基础分支,然后按确定

2.推送分支

<块引用>

右键单击您的项目>>> TortoiseGit >>>推>>>>单击“确定”

3.切换到新分支

<块引用>

右键单击您的项目>>> TortoiseGit >>>切换/结帐>>选择新创建的分支并按确定

如果您使用命令提示符,请按照以下步骤操作:-

1.使用命令提示符创建分支

<块引用>

$git checkout -b new_branch_name

2.推送分支

<块引用>

$git 推送原点 new_branch_name

3.切换到新分支
它已经切换到 new_branch_name 否则你可以使用

<块引用>

$git checkout new_branch_name

I have used two ways to create branch

If you are using TortoiseGit follow these steps:-

1.Create Branch using TortoiseGit

Right click on your project >>> TortoiseGit >>> Create Branch >>> write the name of branch and select the base branch then press ok

2.Push the branch

Right click on your project >>> TortoiseGit >>> push >>> click ok

3.Switch to new branch

Right click on your project >>> TortoiseGit >>> Switch/Checkout >>> select newly created branch and press ok

If you are using command prompt follow these steps:-

1.Create branch using command prompt

$git checkout -b new_branch_name

2.Push the branch

$git push origin new_branch_name

3.Switch to new branch
it will already switched to new_branch_name otherwise you can use

$git checkout new_branch_name

梦断已成空 2024-08-13 10:49:05

我用这个,它非常方便:

git config --global alias.mkdir '!git checkout -b $1; git status; git push -u origin $1; exit;'

用法:git mkdir NEW_BRANCH

你甚至不需要 git status;也许,我只是想确保一切顺利......

您可以使用一个命令同时拥有本地和远程分支。

I use this and it is pretty handy:

git config --global alias.mkdir '!git checkout -b $1; git status; git push -u origin $1; exit;'

Usage: git mkdir NEW_BRANCH

You don't even need git status; maybe, I just want to make sure everything is going well...

You can have BOTH the LOCAL and REMOTE branch with a single command.

俯瞰星空 2024-08-13 10:49:05

我通过将其添加到我的 bash ~/.profile 中解决了这个问题:

function gitb() { git checkout -b $1 && git push --set-upstream origin $1;然后

,为了启动一个新的本地+远程分支,我编写:

gitb feature/mynewbranch

这将创建分支并且进行第一次推送,而不仅仅是设置跟踪(以便稍后的 git pull 和 git push 无需额外参数即可工作),但实际上确认目标存储库中尚不存在此类分支。

I've solved this by adding this into my bash ~/.profile:

function gitb() { git checkout -b $1 && git push --set-upstream origin $1; }

Then to start up a new local + remote branch, I write:

gitb feature/mynewbranch

This creates the branch and does the first push, not just to setup tracking (so that later git pull and git push work without extra arguments), but actually confirming that the target repo doesn't already have such branch in it.

墟烟 2024-08-13 10:49:05

这是一个例子,我只有两个首先是本地的分支:origin 和 mobile-test。

直到我在命令行中使用它来实际在远程分支中显示我更新的文件之前,对我来说没有任何作用。

git push --set-upstream origin mobile-test

Heres an example I only have two branches that were local first: origin and mobile-test.

Nothing for me worked until I used this in command line to actually show my updated files in a remote branch.

git push --set-upstream origin mobile-test
默嘫て 2024-08-13 10:49:05

如果您已使用 --single-branch 克隆当前分支,请使用它从当前分支创建一个新分支:

git checkout -b <new-branch-name>
git push -u origin <new-branch-name>
git remote set-branches origin --add <new-branch-name>
git fetch

If you have used --single-branch to clone the current branch, use this to create a new branch from the current:

git checkout -b <new-branch-name>
git push -u origin <new-branch-name>
git remote set-branches origin --add <new-branch-name>
git fetch
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文