Project scenario:
The project has changed the warehouse address, and the Python project and Java project (both applicable) do not need to re-git clone to clone the warehouse, but directly switch to the new address. The following implements Git to view the current warehouse address and Git to switch the new warehouse address
Git checks the current warehouse address:
方式一:git remote -v
Example:
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
Example:
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 switches the new warehouse address:
.git
Execute in the directory where the file is located: Example
git remote set-url origin 新仓库地址
:
D:\PythonProject>git remote set-url origin https://github.com/Yyyyyyyyy/Yy.git
The above will switch the original warehouse address of the project https://github.com/Xxxxxxxx/Xxxxxx.git to the new warehouse address https://github.com/Yyyyyyyyy/Yy.git
You can git pull origin 分支名
pull the code.