git remote 命令

Git 基本操作Git 基本操作

git remote 命令用于一些對遠程倉庫的操作。

 

1. git remote 命令

git remote 命令可以查看當前配置中有哪些遠程倉庫,列出每個遠程庫的簡短名字。

在克隆完某個項目后,我們可以看到一個名為 origin 的遠程庫,git 默認使用這個名字來標識克隆的原始倉庫。

我們克隆一個遠程倉庫項目,查看一下本地配置中的遠程倉庫列表:

$ git clone https://github.com/owenliang/go-websocket.git
$ cd go-websocket

# git remote 不帶參數,列出已經存在的遠程分支

$ git remote
origin

其中:origin 是遠程倉庫的默認別名,在很多命令中可以直接代替遠程倉庫的 Url 使用。

 

2. git remote -v 命令

列出每個遠程庫的詳細信息,在每一個名字后面列出其遠程 url。

我們查看一下本地配置中的遠程倉庫詳細列表:

$ git remote -v

origin	https://github.com/owenliang/go-websocket.git (fetch)
origin	https://github.com/owenliang/go-websocket.git (push)

 

3. git remote add 命令

用于添加本地配置中的一個遠程倉庫。

git remote add [shortname] [url]

[shortname] 為遠程倉庫的別名,比如 origin 是系統(tǒng)默認的遠程倉庫別名。

[url] 為遠程倉庫的 Url 地址,比如 https://github.com/owenliang/go-websocket.git。

我們添加一個遠程倉庫,別名為 myproject:

$ git remote add myproject https://github.com/owenliang/go-websocket.git

$ git remote -v
myproject	https://github.com/owenliang/go-websocket.git (fetch)
myproject	https://github.com/owenliang/go-websocket.git (push)
origin	https://github.com/owenliang/go-websocket.git (fetch)
origin	https://github.com/owenliang/go-websocket.git (push)

 

4. git remote rm 命令

用于刪除本地配置中的一個遠程倉庫。

git remote rm [shortname]

[shortname] 為遠程倉庫的別名,比如 myproject。

我們刪除本地配置中的一個遠程倉庫 myproject:

$ git remote rm myproject

$ git remote -v
origin	https://github.com/owenliang/go-websocket.git (fetch)
origin	https://github.com/owenliang/go-websocket.git (push)

 

5. git remote rename 命令

用于重命名本地配置中的一個遠程倉庫。

git remote rename [shortname] [new shortname]

[shortname] 為遠程倉庫的別名。

[new shortname] 為遠程倉庫的新的別名。

我們將本地配置中的遠程倉庫 myproject 改名為 myproject1:

$ git remote rename myproject myproject1

$ git remote -v
myproject1	https://github.com/owenliang/go-websocket.git (fetch)
myproject1	https://github.com/owenliang/go-websocket.git (push)
origin	https://github.com/owenliang/go-websocket.git (fetch)
origin	https://github.com/owenliang/go-websocket.git (push)

 

Git 基本操作Git 基本操作

丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清