gpt4 book ai didi

尽管设置了 upstream-to 和 push.default,Git 仍推送 HEAD -> master

转载 作者:太空狗 更新时间:2023-10-29 14:43:43 30 4
gpt4 key购买 nike

我有一个 git 存储库,使用了几年没有问题。我使用 SmartGit 来方便地做大多数事情。

我最近注意到,在从 dev 分支从 SmartGit 进行推送时,它显示的确认对话框显示“将当前分支‘dev’推送到‘master’”,而不是像以前那样从 dev 到 dev。

我切换到 git cmd 行来比较行为,发现它也想推送到 master:

$ git push --dry-run
To https://github.com/some_repo.git
c00bb9e..6a8ade4 HEAD -> master

使用 refspec 推送按预期工作,但我似乎无法找到一种方法来告诉 SmartGit 使用该 refspec 或者它如何决定它将推送 dev -> master。

$ git push origin dev --dry-run
To https://github.com/some_repo.git
428dd9b..6a8ade4 dev -> dev

Git 状态和引用按预期显示:

$git status
On branch dev
Your branch is ahead of 'origin/dev' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean

$ git symbolic-ref HEAD
refs/heads/dev

我的配置 push.default 设置为“简单”,这应该意味着当前将推送到远程上的相同名称,如果不匹配则提示。

git config push.default
simple

我还重置了“upstream-to”,但仍然是一个普通的 git push 最终想要执行 HEAD -> master。

$git branch --set-upstream-to origin/dev
Branch dev set up to track remote branch dev from origin by rebasing.

我不知道这可能是什么原因,以及如何回到一个简单的 git push 去匹配 current 的分支和/或如何让 SmartGit 停止提供推送 current -> master。

Git 版本:2.5.0

SmartGit 版本:8.0.3 #8135

最佳答案

来自 git-push(1) :

When the command line does not specify what to push with <refspec>... arguments or --all, --mirror, --tags options, the command finds the default <refspec> by consulting remote.*.push configuration, and if it is not found, honors push.default configuration to decide what to push (See git-config(1) for the meaning of push.default).

听起来你有 remote.dev.push设置为 HEAD .

关于尽管设置了 upstream-to 和 push.default,Git 仍推送 HEAD -> master,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41513139/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com