Windowsでリモート/ターゲットリポジトリのURLを変更するにはどうすればよいですか? [複製]
質問
この質問にはすでに回答があります:
WindowsでローカルGITリポジトリを作成しました。それをAAAと呼びましょう。コンテンツをステージングし、コミットし、GitHubにプッシュしました。 git@github.com:username / AAA.git
名前を間違えたことがわかりました。
GitHubで、 git@github.com:username / BBB.git
に名前を変更しました
今、私のWindowsマシンでは、 git@github.com:username / AAA.git
を git@github.com:username / BBB.git
設定がまだ「プッシュ」しようとしているためです; git@github.com:username / AAA.git
に移動しますが、今すぐ git@github.com:username / BBB.git
にプッシュする必要があります。
どうすればそれができますか?
解決
私の意見では、これを微調整する最も簡単な方法(imho)は、リポジトリの.git / configファイルを編集することです。混乱したエントリを探して、URLを微調整します。
レポジトリのマシンでは、次のように定期的に使用しています。
KidA% cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
autocflg = true
[remote "origin"]
url = ssh://localhost:8888/opt/local/var/git/project.git
#url = ssh://xxx.xxx.xxx.xxx:80/opt/local/var/git/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
コメントアウトされている行は、リポジトリの代替アドレスであり、コメントアウトされている行を変更するだけで切り替えられることがあります。
これは、 git remote rm
や git remote add
のようなものを実行すると内部で操作されるファイルですが、この場合はこの方法で修正するのが理にかなっているかもしれません。
他のヒント
git remote set-url origin <URL>
これを行うもう1つの方法は次のとおりです。
git config remote.origin.url https://github.com/abc/abc.git
既存のURLを確認するには、次のようにします。
git config remote.origin.url
.git / configを見て、必要な変更を加えます。
代わりに使用できます
git remote rm [name of the url you sets on adding]
and
git remote add [name] [URL]
または単に
git remote set-url [URL]
何か間違ったことをする前に、もう一度確認してください
git help remote