プロジェクトのシナリオ:
プロジェクトはウェアハウスのアドレスを変更しました。Python プロジェクトと Java プロジェクト (どちらも該当) は、ウェアハウスのクローンを作成するために git clone を再実行する必要はなく、新しいアドレスに直接切り替える必要があります。以下は、現在の倉庫アドレスを表示するための Git と、新しい倉庫アドレスを切り替えるための Git を実装しています。
Git は現在の倉庫のアドレスを確認します。
方式一:git remote -v
例:
D:\PythonProject>git remote -v
origin https://github.com/Xxxxxxxx/Xxxxxx.git (fetch)
origin https://github.com/Xxxxxxxx/Xxxxxx.git (push)
方式二:git remote show origin
例:
D:\PythonProject>git remote show origin
* remote origin
Fetch URL: https://github.com/Xxxxxxxx/Xxxxxx.git
Push URL: https://github.com/Xxxxxxxx/Xxxxxx.git
HEAD branch: master
Remote branches:
master tracked
Local branches configured for 'git pull':
master merges with remote master
Local refs configured for 'git push':
master pushes to master (up to date)
Git は新しいウェアハウスのアドレスを切り替えます。
.git
ファイルが置かれているディレクトリで実行します。例
git remote set-url origin 新仓库地址
:
D:\PythonProject>git remote set-url origin https://github.com/Yyyyyyyyy/Yy.git
上記により、プロジェクトの元のウェアハウス アドレス https://github.com/Xxxxxxxx/Xxxxxx.git が新しいウェアハウス アドレス https://github.com/Yyyyyyyyy/Yy.git に切り替わります。
git pull origin 分支名
コードを引っ張ることができます。