赞
踩
git remote -v 命令用于显示远程仓库的详细信息。-v 或 --verbose 参数的意思是 “verbose”,它会输出每个远程仓库的详细信息,包括其名称和对应的克隆(Fetch)和推送(Push)的URL。
这个命令常用于检查你当前的 Git 项目配置了哪些远程仓库,以及这些远程仓库的 URL 是什么。
示例:
$ git remote -v
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
在这个例子中,我们有一个名为 origin 的远程仓库。当你执行 git push 或 git pull 而不指定远程仓库时,Git 默认使用 origin 作为远程仓库。
如果你有多个远程仓库,git remote -v 会列出所有远程仓库的信息:
$ git remote -v
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
bitbucket https://bitbucket.org/user/repo.git (fetch)
bitbucket https://bitbucket.org/user/repo.git (push)
在这个例子中,除了 origin,我们还有一个名为 bitbucket 的远程仓库。这可以帮助你同时向 GitHub 和 Bitbucket 推送代码,或者从这两个平台拉取代码。
git remote show命令用于显示远程仓库的详细信息。它会列出远程仓库的URLs、拉取和推送的默认分支等信息。
示例:
假设您已经添加了一个名为origin的远程仓库,您可以使用以下命令来查看它的详细信息:
git remote show origin
如果您想查看所有远程仓库的信息,可以省略远程仓库的名称:
git remote show
如果您只想显示远程仓库的URL而不显示分支信息,可以使用-n选项:
git remote show -n origin
如果您想看到更详细的信息,包括每个分支对应的远程分支,可以使用–verbose选项:
git remote show --verbose origin
这些命令会提供关于您的远程仓库配置的有用信息,帮助您理解与远程仓库的交互。
git remote add 是一个Git命令,用于添加一个新的远程仓库地址。
git remote add <shortname> <url>
其中 是远程仓库的简称,通常为 origin,而 是远程仓库的URL。
例如,要添加一个名为 origin 的远程仓库,URL 为 https://github.com/user/repo.git,你可以使用以下命令:
git remote add origin https://github.com/user/repo.git
如果你想添加多个远程仓库,可以使用不同的简称,如 upstream 和 fork。例如:
git remote add upstream https://github.com/original/repo.git
git remote add fork https://github.com/your-username/repo.git
这样,你就可以分别从 upstream 和 fork 获取和推送代码。
关于《Git常用命令》详细讲解这篇文章,老吕也没想到,随手写啊写啊,Git命令详细的写一写还真的写了好多内容,直接发布后,发现手机看这文章的时候,居然卡屏了,所以无奈只能把这篇文章的内容分拆成10篇发布出来,以下是全文各篇章的链接:
1. 《Git常用命令》详细讲解·第1篇(git clone和git init)
https://pythonlaolv.blog.csdn.net/article/details/137091558
2. 《Git常用命令》详细讲解·第2篇(git status和git diff)
https://pythonlaolv.blog.csdn.net/article/details/137095087
3. 《Git常用命令》详细讲解·第3篇(git add、git mv和git rm)
https://pythonlaolv.blog.csdn.net/article/details/137095175
4. 《Git常用命令》详细讲解·第4篇(git commit -m “commit message“和git commit --amend)
https://pythonlaolv.blog.csdn.net/article/details/137095289
5. 《Git常用命令》详细讲解·第5篇(git log和git blame)
https://pythonlaolv.blog.csdn.net/article/details/137095352
6. 《Git常用命令》详细讲解·第6篇(git reset --hard HEAD、git checkout HEAD和git revert <commit>)
https://pythonlaolv.blog.csdn.net/article/details/137095501
7. 《Git常用命令》详细讲解·第7篇(git branch、git checkout <branch/tag>和git tag)
https://pythonlaolv.blog.csdn.net/article/details/137095635
8. 《Git常用命令》详细讲解·第8篇(git merge和git rebase)
https://pythonlaolv.blog.csdn.net/article/details/137095700
9. 《Git常用命令》详细讲解·第9篇(git remote -v、git remote show和git remote add)
https://pythonlaolv.blog.csdn.net/article/details/137095791
10. 《Git常用命令》详细讲解·第10篇(git fetch、git pull和git push)
https://pythonlaolv.blog.csdn.net/article/details/137111309
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。