在我们的项目中,我们一直使用本地 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 不允许我添加屏幕截图。)
- 从您的存储库备份
./git/config
(以防万一) - 删除所有
[branch "..."]
和[remote "..."]
部分,并保存文件。 - 在 Git Extensions 菜单中选择
Repository -> Remote repositories...
- 在
Name
中输入您喜欢的内容,例如origin_remote
- 在
Url
中输入您要推送到/从中提取的 URL - 按
保存更改
New remote
对话框会 popDo you want to automatically configure the default push and pull behavior for this remote?
按
是
。这应该会自动添加远程分支引用并执行运行git remote update
。关闭对话框并刷新 Git 扩展以在存储库图(浏览) View 中查看远程引用的状态。它们应该看起来像本地分支机构,但颜色为绿色且名称格式为origin_remote/your_branch_name
现在,当您在
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/