博文目录
Git 一份代码如何同时提交并推送到两个仓库
Git - 将一个项目同时从本地推送到 GitHub 和 Gitee
一份代码如何同时提交并推送到两个仓库, 需要明确从哪个仓库拉取代码
查看仓库绑定情况
git remote -v
origin git@e.coding.net:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (fetch)
origin git@e.coding.net:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (push)
再绑定另外一个远程仓库, 该仓库只推不拉
git remote set-url --add origin git@github.com:mrathena/python.apex.weapon.auto.recognize.and.suppress.git
git remote -v
origin git@e.coding.net:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (fetch)
origin git@e.coding.net:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (push)
origin git@github.com:mrathena/python.apex.weapon.auto.recognize.and.suppress.git (push)
这时候执行推送, 大概率只能成功推到第一个仓库, 后绑定的仓库会拒绝, 要求先获取一次
可以执行 git push -f
强制推送一次, 后续 git push
就正常了
其他情况见参考文章
GitHub ssh: connect to host github.com port 22: Connection timed out
ssh: connect to host github.com port 22: Connection refused
如果 GitHub push 时出现如下内容, 包含 ssh: connect to host github.com port 22: Connection timed out
字样, 无法 push文章来源:https://www.toymoban.com/news/detail-400380.html
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
首先输入 ssh -T git@github.com
检查SSH是否能够连接成功, 如果提示 ssh: connect to host github.com port 22: Connection timed out
则说明 22 端口可能真的不通了, 可以通过下面方法换成 443 端口文章来源地址https://www.toymoban.com/news/detail-400380.html
- 在
C:\Users\mrathena\.ssh
中新建文本文件config
, 内容如下Host github.com User GitHub 邮箱 Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_ecdsa # id_rsa 可能已经被 GitHub 封了, 我现在用的是 id_ecdsa Port 443
- 再次输入
ssh -T git@github.com
, 根据提示输入yes
, 提示You've successfully authenticated
则配置成功The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This host key is known by the following other names/addresses: C:\Users\mrathena/.ssh/known_hosts:2: github.com Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts. Hi mrathena! You've successfully authenticated, but GitHub does not provide shell access.
- 再次 push 将成功
到了这里,关于Git 一份代码如何同时提交并推送到两个仓库的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!