相关疑难解决方法(0)

让现有的Git分支跟踪一个远程分支?

我知道如何创建一个跟踪远程分支的新分支,但是如何使现有分支跟踪远程分支?

我知道我可以编辑.git/config文件,但似乎应该有一个更简单的方法.

git branch git-branch

3437
推荐指数
19
解决办法
129万
查看次数

为什么我需要一直做`--set-upstream`?

我在Git中创建了一个新分支:

git branch my_branch
Run Code Online (Sandbox Code Playgroud)

推它:

git push origin my_branch
Run Code Online (Sandbox Code Playgroud)

现在说有人在服务器上做了一些更改,我想从中拉出来origin/my_branch.我做:

git pull
Run Code Online (Sandbox Code Playgroud)

但我得到:

You asked me to pull without telling me which branch you
want to merge with, and 'branch.my_branch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like …
Run Code Online (Sandbox Code Playgroud)

git git-branch

1364
推荐指数
18
解决办法
93万
查看次数

如何在没有--set-upstream的情况下推送远程服务器上不存在的新分支?

这种情况是我在远程服务器上没有存储库,只有一个帐户。然后,我在本地运行以下命令,其中x是用户名,y是仅存在于我的本地系统上的项目名称。

git init  
git remote add buckety https://x@bitbucket.org/x/y.git  
git add .  
git commit --message "Here we go..."  
git push buckety
Run Code Online (Sandbox Code Playgroud)

现在我收到错误提示我设置远程上游。我可以这样做(--set-upstream或者-u),但是根据我的 googlearching,它已被弃用。(实际上很奇怪,控制台中的建议仍然提到它。)

我想以正确的方式做到这一点,并且我已经搜索了--track--set-upstream-to。但是,就我所见,我在 Git 上的特定场景没有示例,并且我测试的操作因错误而失败。

我应该如何在不撤回使用已弃用选项的情况下创建远程分支?我可能想在远程创建一个跟踪分支,以便:

  1. 本地分支 A 对应远程分支 A,但也
  2. 本地分支 A 对应远程分支 B。

最好,我想在推送之前配置它,但我不确定如何配置。我无法使用结帐,因为该分支尚不存在。出于同样的原因,我不能使用set-upstream-to

git version-control branch git-branch

7
推荐指数
1
解决办法
7868
查看次数

标签 统计

git ×3

git-branch ×3

branch ×2

version-control ×1