【git】git remote

git remote

 在下图中,git init、git add和git commit都是前期准备,相当于将你本地的文件上传到本地仓库,但是还没有向远程仓库提交。

在这时执行git remote add 命令,就是将本地仓库与远程仓库建立连接, git remote add命令中,add什么呢?蓝色的方框其实就是为远程仓库命名,一般都是叫origin,其实可以叫其他的名字,绿色方框就是你远程仓库的真实地址。

 

显示所有远程仓库:

git remote -v

 

显示某个远程仓库的信息

git remote show [remote]

输出:

git remote show https://github.com/tianqixin/runoob-git-test
* remote https://github.com/tianqixin/runoob-git-test
  Fetch URL: https://github.com/tianqixin/runoob-git-test
  Push  URL: https://github.com/tianqixin/runoob-git-test
  HEAD branch: master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

 

添加远程仓库

git remote add [shortname] [url]

 

删除远程仓库:

git remote rm [name]

 

修改仓库名:

git remote rename [old_name] [new_name]

 

 

同步本地的远程分析

1. 查看本地分支和追踪情况

git remote show origin

可以发现红框中的分支是远程分支已被删除的分支,根据提示可以使用 git remote prune 来同步删除这些分支。

运行命令:

git remote prune origin

posted @ 2022-07-24 21:16  苏格拉底的落泪  阅读(897)  评论(0)    收藏  举报