Git: "The branch you are about to push seems to be a new branch for the remote"警告

标签 git git-push git-remote

在我们的项目中,我们一直使用本地 IP 地址作为源。现在,我们已经转移到现场工作,需要使用远程 ip 进行推送/pull 。

使用 manage remotes 选项,我已将新 ip 保存为 origin_remote 并尝试将我的代码推送到那里,但由于某种原因,我收到此警告(或信息消息).我不确定我是否做错了什么。因为我只是更改 ip 并基本上推送到同一个 repo,所以操作不应该很顺利吗?为什么 git 告诉我这是一个新分支?

最佳答案

其他答案已经涵盖了为什么会发生这种情况,并解释说这不是 Git,而是 GitExtensions 警告。

所以我会建议一些尝试让消息消失。我在 Windows 7 上使用 Git 扩展 2.48.05 和 git 版本 1.9.5.msysgit.0 在两个虚拟存储库上测试了它.(此时 Stack Overflow 不允许我添加屏幕截图。)

  1. 从您的存储库备份 ./git/config(以防万一)
  2. 删除所有 [branch "..."][remote "..."] 部分,并保存文件。
  3. 在 Git Extensions 菜单中选择 Repository -> Remote repositories...
  4. Name 中输入您喜欢的内容,例如 origin_remote
  5. Url 中输入您要推送到/从中提取的 URL
  6. 保存更改
  7. New remote 对话框会 pop

    Do you want to automatically configure the default push and pull behavior for this remote?

  8. 。这应该会自动添加远程分支引用并执行运行 git remote update。关闭对话框并刷新 Git 扩展以在存储库图(浏览) View 中查看远程引用的状态。它们应该看起来像本地分支机构,但颜色为绿色且名称格式为 origin_remote/your_branch_name

  9. 现在,当您在 Remote 字段中使用 Push 对话框时,请选择 origin_remote。您应该不会再看到任何警告。

最后,您应该在本地存储库的 ./git/config 中得到类似这样的内容:

[remote "origin_remote"]
    url = URL_TO_YOUR_REPOSITORY
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "your_branch_name"]
    remote = origin_remote
    merge = refs/heads/your_branch_name
[branch "your_other_branch_name"]
    remote = origin_remote
    merge = refs/heads/your_other_branch_name

关于Git: "The branch you are about to push seems to be a new branch for the remote"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17146581/

相关文章:

git - "git init"失败,怎么了?

Git/Diff Patch 技术讲解

image - Git push 卡在 POST git-receive-pack 上

git - 如何将新的本地分支推送到远程 Git 存储库并跟踪它?

git - 删除本地跟踪

git 子模块 : track 2 branches

git - "src"属性中的模式不匹配任何文件“React.js

github 访问拒绝访问推送

git - 我如何 git remote prune 只是一个特定的远程分支?

git - 在 Azure Devops 中创建分支时对作者的说明