git remote简单记录

Git2024年8月6日 pm5:03发布1个月前更新 91es.com站长
75 0 0
目录

前言

之前也就使用,没有做记录,这次抽空记录下git remote的使用。

记录于此,方便自己查阅。

正文

下面是git remote的命令,虽然很多,但大多数都不是常用。

$ git remote -h

usage: git remote [-v | --verbose]
   or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url>
   or: git remote rename <old> <new>
   or: git remote remove <name>
   or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
   or: git remote [-v | --verbose] show [-n] <name>
   or: git remote prune [-n | --dry-run] <name>
   or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...]
   or: git remote set-branches [--add] <name> <branch>...
   or: git remote get-url [--push] [--all] <name>
   or: git remote set-url [--push] <name> <newurl> [<oldurl>]
   or: git remote set-url --add <name> <newurl>
   or: git remote set-url --delete <name> <url>

    -v, --verbose         be verbose; must be placed before a subcommand

下面记录一下自己常用的

git remote

显示远程仓库

$ git remote
origin

origin为远程地址的别名。

别名更容易记住。

git remote -v

git remote -v用于显示当前仓库中配置的远程仓库名以及对应的URL

$ git remote -v
origin  http://192.168.1.18/ac80xx/ac80xx-project.git (fetch)
origin  http://192.168.1.18/ac80xx/ac80xx-project.git (push)

远程仓库别名 : origin

远程仓库URL :http://192.168.1.18/ac80xx/ac80xx-project.git

git remote show

git remote show [remote]

比如

$ git remote show http://192.168.1.18/ac80xx/ac80xx-project.git

* remote http://192.168.1.18/ac80xx/ac80xx-project.git
  Fetch URL: http://192.168.1.18/ac80xx/ac80xx-project.git
  Push  URL: http://192.168.1.18/ac80xx/ac80xx-project.git
  HEAD branch: master
  Local ref configured for 'git push':
    biumall_V5 pushes to biumall_V5 (up to date)

git remote add

git remote add <remote_name> <remote_url>
  • <remote_name>:要添加的远程仓库的名称。通常,远程仓库的名称为 origin,但你也可以自定义一个名称。

  • <remote_url>:远程仓库的 URL。它可以是一个指向远程 Git 仓库的 HTTPS、SSH 或 Git 协议链接。

向当前仓库添加一个名为 origin 的远程仓库,假定URL是 http://192.168.1.18/ac80xx/ac80xx-project.git

git remote add origin http://192.168.1.18/ac80xx/ac80xx-project.git

如果origin已经存在会提示如下,

fatal: remote origin already exists.

也就是说当已经添加了远程仓库。

如果是换仓库URL,可以改一下仓库名字,比如origin_new,先添加,然后移除老的进行切换。

git remote add origin_new git@192.168.1.18:ac80xx/ac80xx-project.git

git@192.168.1.18:ac80xx/ac80xx-project.git和http://192.168.1.18/ac80xx/ac80xx-project.git是同一个仓库,只不过不同的协议链接。

git remote rm

移除远程仓库

git remote rm <remote_name>

上面我们新增了origin_new,这里就删除之前老的origin远程仓库。

git remote rm origin

git remote rename

修改远程仓库名

git remote rename old_name new_name

老仓库origin已经删了,给origin_new重新命名。

git remote rename origin_new origin

参考文章

  1. git remote 命令

 历史上的今天

  1. 2023: SurfaceView和TextureView介绍(0条评论)
  2. 2021: 许立志:我谈到血(0条评论)
  3. 2021: 周国平:事故(0条评论)
  4. 2019: 聂鲁达:雨(0条评论)
  5. 2018: Git 常用命令之git log(0条评论)
版权声明 1、 本站名称: 91易搜
2、 本站网址: 91es.com3xcn.com[备用域名]
3、 本站内容: 部分来源于网络,仅供站长学习和参考,若侵权请留言

暂无评论

暂无评论...

随机推荐

记录阅读背景色和文字颜色

记录一下阅读背景色和文字颜色搭配,方便自己查阅。内容摘抄的,链接在文末。纯白的背景色加上纯黑的文字,两极反的色感,很快就给人的眼睛带来刺激,看了不到一会儿就出现眼睛酸涩的感觉,不适合护眼。如何减轻眼睛的疲惫感呢?换个柔和的颜色。像纸质的淡黄色就很不错。在这里我收藏了一些柔和的背景颜色。文字和背景...

LocalServices和SystemService等简介

前言在上次简单介绍SystemServer(《SystenServer的启动之一》)时,里面涉及几个比较重要的类SystemServiceManager,SystemService和LocalServices,因此今天就单独介绍一下。正文涉及文件frameworks\base\servic...

Kotlin的基本语法

前言简单记录一下Kotlin的基本语法。这里只是简单的记录,只是方便自己而已。正文注释注释是为了使代码易于阅读。单行注释单行注释通常是对程序中的某一行代码进行解释,用符号“//”表示//初始化UIinitUI();多行注释多行注释就是注释中的内容可以是多行,以符号“/ ”开...

C语言之scanf()

前言简单记录一下scanf的使用。scanf()函数根据由format(格式)指定的格式从stdin(标准输入)读取,并保存数据到其它参数。正文scanf说明语法:#include <stdio.h> int scanf( const char *format, ... ...

Android系统切换语言后,Activity中的文本没有改变

前言切换语言后,项目中的APP中的文本没有根据系统的语言改变而改变。这个是个小问题,但还是记录一下,方便自己查阅。正文隐藏内容!付费阅读后才能查看!¥1 ¥3多个隐藏块只需支付一次付费阅读参考文章《[摘]切换多国语言导致Fragment被回收,出现切换错乱》

《MySQL基础教程》笔记4

前言本文主要是select语句的使用学习一下MySQL,一直没有系统的学习一下。最近有空,看了《MySQL基础教程-西泽梦路》,简单的做一下笔记。记录于此,方便自己回忆。MySQL中对大小写没有区分,我这里习惯性用小些。正文我这以Window版的phpstudy软件验证。需要进入...