Git で同時に 2 つのウェアハウスにコードを送信してプッシュする方法

ブログ投稿ディレクトリ


Git で同時に 2 つのウェアハウスにコードを送信してプッシュする方法

Git - プロジェクトをローカルから GitHub と Gitee に同時にプッシュする

コードを 2 つのウェアハウスに同時に送信してプッシュする方法。どのウェアハウスからコードをプルするかを指定する必要があります。

倉庫バインディングを表示

git remote -v

origin  [email protected]:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (fetch)
origin  [email protected]:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (push)

次に、別のリモート倉庫をバインドします。倉庫はプッシュのみできますが、プルはできません

git remote set-url --add origin [email protected]:mrathena/python.apex.weapon.auto.recognize.and.suppress.git
git remote -v

origin  [email protected]:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (fetch)
origin  [email protected]:mrathena/code.study/python.apex.weapon.auto.recognize.and.suppress.git (push)
origin  [email protected]:mrathena/python.apex.weapon.auto.recognize.and.suppress.git (push)

このとき、プッシュを実行すると、高確率で最初の倉庫にしかプッシュできず、後でバウンドする倉庫は拒否して一度取得するように求めます。

git push -f強制プッシュを1回行うことができ、フォローアップgit pushは正常になります

その他の場合は参考記事を参照

GitHub ssh: ホスト github.com ポート 22 に接続: 接続がタイムアウトしました

ssh: ホスト github.com ポート 22 に接続: 接続が拒否されました

GitHub プッシュ中に、ssh: connect to host github.com port 22: Connection timed outという単語、プッシュできません。

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 接続が成功したかどうかssh -T [email protected]を確認します。プロンプトが表示された場合はssh: connect to host github.com port 22: Connection timed out、ポート 22 が本当に使用できない可能性があることを意味します。次の方法を使用して、ポート 443 に変更できます。

  • C:\Users\mrathena\.sshconfig、次の内容の新しいテキスト ファイルを作成します。
    Host github.com
    User GitHub 邮箱
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_ecdsa # id_rsa 可能已经被 GitHub 封了, 我现在用的是 id_ecdsa 
    Port 443
    
  • もう一度入力してssh -T [email protected]、プロンプトに従って入力し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.
    
  • もう一度押すと成功します

おすすめ

転載: blog.csdn.net/mrathena/article/details/128173637