git - 更改 Git 远程 'push to' 默认值

标签 git git-push git-remote

我想更改 Git 默认的远程分支目的地,这样我就可以了

git push

代替:

git push upstream

目前这被设置为原始 Remote ,我想将它设置为不同的 Remote 。

我试图删除原始(克隆自)远程

git remote rm origin

确实移除了原来的 Remote 。但是没有解决 git push 问题。我仍然得到:

fatal: No configured push destination. Either specify the URL from the
command-line or configure a remote repository using...

我也试过玩:

git remote set-url --push myfork origin

和其他选项,但似乎都不起作用(可能是因为我太早删除了 origin Remote ?)

answer here 之后我试图改变:

git config push.default upstream (or matching)

但都没有用。

最佳答案

您可以使用 git push -u <remote_name> <local_branch_name>设置默认上游。查看documentation for git push了解更多详情。

关于git - 更改 Git 远程 'push to' 默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18801147/

相关文章:

git - 在git中取消暂存已删除的文件

通过 ssh 推送时 Git 推送挂起

git - 如何更改远程 Git 存储库的 URI (URL)?

git - 如何推送 .gitignore 中指定的文件?

git - 创建远程 Git 分支作为 SVN 存储库的特定 git-svn 分支的镜像

Git:修改工作目录时如何检查本地分支是否领先于远程分支?

git - 在 Windows 计算机上设置 Git 服务器

git - 如何查看 git 子模块指向哪个提交

WordPress作为git子模块,不小心通过WP admin更新而不是git,现在修改了内容

git - 没有指定分支的 "git push"的默认行为