?
This document uses PHP Chinese website manual Release
git-remote - 管理追蹤存儲(chǔ)庫(kù)的集合
git remote [-v | --verbose]git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>git remote rename <old> <new>git remote remove <name>git remote set-head <name> (-a | --auto | -d | --delete | <branch>)git remote set-branches [--add] <name> <branch>… git remote get-url [--push] [--all] <name>git remote set-url [--push] <name> <newurl> [<oldurl>]git remote set-url --add [--push] <name> <newurl>git remote set-url --delete [--push] <name> <url>git remote [-v | --verbose] show [-n] <name>… git remote prune [-n | --dry-run] <name>… git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)…]
管理您追蹤分支的一組存儲(chǔ)庫(kù)(“遠(yuǎn)程”)。
-v --verbose
稍微詳細(xì)一點(diǎn),并在名稱(chēng)后顯示遠(yuǎn)程 URL 。注意:這必須放在remote
和之間subcommand
。
沒(méi)有參數(shù),顯示現(xiàn)有遙控器的列表。幾個(gè)子命令可用于在遙控器上執(zhí)行操作。
add
在 <url> 處添加一個(gè)名為 <name> 的存儲(chǔ)庫(kù)。該命令git fetch <name>
然后可用于創(chuàng)建和更新遠(yuǎn)程跟蹤分支<name> / <branch>。
使用-f
選項(xiàng),git fetch <name>
在遠(yuǎn)程信息設(shè)置完成后立即運(yùn)行。
使用--tags
選項(xiàng),git fetch <name>
從遠(yuǎn)程存儲(chǔ)庫(kù)導(dǎo)入每個(gè)標(biāo)記。
使用--no-tags
選項(xiàng),git fetch <name>
不會(huì)從遠(yuǎn)程存儲(chǔ)庫(kù)導(dǎo)入標(biāo)簽。
默認(rèn)情況下,只有取回分支上的標(biāo)簽被導(dǎo)入(參見(jiàn) git-fetch [1])。
使用-t <branch>
選項(xiàng),而不是遠(yuǎn)程的默認(rèn) glob refspec 來(lái)跟蹤refs/remotes/<name>/
命名空間下的所有分支,將<branch>
創(chuàng)建僅用于跟蹤的 refspec 。您可以給-t <branch>
多個(gè)分支追蹤多個(gè)分支,而無(wú)需抓取所有分支。
使用-m <master>
選項(xiàng),符號(hào)引用refs/remotes/<name>/HEAD
被設(shè)置為指向遠(yuǎn)程的<master>
分支。另請(qǐng)參閱 set-head 命令。
當(dāng)創(chuàng)建獲取鏡像時(shí)--mirror=fetch
,參考將不會(huì)存儲(chǔ)在refs/remotes/
命名空間中,而是refs/
將遠(yuǎn)程中的所有內(nèi)容直接鏡像到refs/
本地存儲(chǔ)庫(kù)中。這個(gè)選項(xiàng)在裸存儲(chǔ)庫(kù)中才有意義,因?yàn)樘崛?huì)覆蓋任何本地提交。
當(dāng)創(chuàng)建一個(gè)推式鏡像時(shí)--mirror=push
,它git push
總是表現(xiàn)得好像--mirror
被傳遞一樣。
rename
將名為 <old> 的遠(yuǎn)程重命名為 <new> 。遠(yuǎn)程的所有遠(yuǎn)程跟蹤分支和配置設(shè)置都會(huì)更新。
如果 <old> 和 <new> 相同,并且 <old> 是$GIT_DIR/remotes
或者下的文件$GIT_DIR/branches
,則將遠(yuǎn)程轉(zhuǎn)換為配置文件格式。
remove rm
刪除名為 <name> 的遠(yuǎn)程。遠(yuǎn)程的所有遠(yuǎn)程跟蹤分支和配置設(shè)置均被刪除。
set-head
設(shè)置或刪除refs/remotes/<name>/HEAD
指定遠(yuǎn)程的默認(rèn)分支(即 symbolic-ref 的目標(biāo))。有一個(gè)遠(yuǎn)程的默認(rèn)分支不是必需的,但允許指定遠(yuǎn)程的名稱(chēng)來(lái)代替特定的分支。例如,如果默認(rèn)分支for origin
設(shè)置為master
,則origin
可以在通常指定的任何位置指定origin/master
。
使用-d
或 --delete
,符號(hào) ref refs/remotes/<name>/HEAD
被刪除。
使用-a
或--auto
,遠(yuǎn)程被查詢來(lái)確定它HEAD
,然后
symbolic-ref refs/remotes/<name>/HEAD
被設(shè)置為同一分支。例如,如果遠(yuǎn)程HEAD
正指向next
“ git remote set-head origin -a
”將設(shè)置符號(hào) -REF refs/remotes/origin/HEAD
到refs/remotes/origin/next
。這只有在refs/remotes/origin/next
已經(jīng)存在的情況下才有效; 如果不是,它必須先取得。
用于顯式<branch>
設(shè)置符號(hào)引用refs/remotes/<name>/HEAD
。例如,“GIT 中遠(yuǎn)程設(shè)置頭原點(diǎn)主”將設(shè)置符號(hào) -REF refs/remotes/origin/HEAD
到refs/remotes/origin/master
。這只有在refs/remotes/origin/master
已經(jīng)存在的情況下才有效; 如果不是,它必須先取得。
set-branches
更改已命名遠(yuǎn)程所跟蹤分支的列表。這可以用于在遠(yuǎn)程初始設(shè)置后跟蹤可用遠(yuǎn)程分支的一個(gè)子集。
指定的分支將被解釋為與命令行中的-t
選項(xiàng)一起指定git remote add
。
隨著--add
的,而不是替換當(dāng)前跟蹤的分支列表,添加到列表中。
get-url
檢索遠(yuǎn)程的 URL 。這里的配置insteadOf
和pushInsteadOf
擴(kuò)展。默認(rèn)情況下,僅列出第一個(gè) URL 。
使用--push
,查詢推送 URL 而不是獲取 URL 。
與--all
,遠(yuǎn)程的所有 URL 將被列出。
set-url
更改遠(yuǎn)程的 URL 。為匹配 regex <oldurl> 的遠(yuǎn)程 <name> 設(shè)置第一個(gè) URL(如果沒(méi)有給出 <oldurl> ,則為第一個(gè) URL )為 <newurl> 。如果 <oldurl> 與任何 URL 都不匹配,則會(huì)發(fā)生錯(cuò)誤并且沒(méi)有任何更改。
使用時(shí)--push
,推送網(wǎng)址將被操縱,而不是抓取網(wǎng)址。
隨著--add
,而不是改變現(xiàn)有的 URL ,新的 URL 添加。
用--delete
,而不是改變現(xiàn)有的 URL ,所有匹配正則表達(dá)式
<URL> URL 被用于遠(yuǎn)程 <name> 刪除。試圖刪除所有非推送網(wǎng)址是一個(gè)錯(cuò)誤。
請(qǐng)注意,即使可以設(shè)置不同的推送網(wǎng)址和提取網(wǎng)址,仍必須引用相同的地方。您推送到推送網(wǎng)址的內(nèi)容應(yīng)該是您立即從提取網(wǎng)址獲取的內(nèi)容。如果您試圖從一個(gè)地方(例如上游)獲取數(shù)據(jù)并推送到另一個(gè)地方(例如您的發(fā)布存儲(chǔ)庫(kù)),請(qǐng)使用兩個(gè)單獨(dú)的遙控器。
show
給出關(guān)于遠(yuǎn)程 <name> 的一些信息。
通過(guò)-n
選項(xiàng),遠(yuǎn)程頭不首先被查詢git ls-remote <name>
; 取而代之的是使用緩存的信息。
prune
刪除 <name> 下的所有陳舊的遠(yuǎn)程追蹤分支。這些陳舊的分支已從 <name> 引用的遠(yuǎn)程存儲(chǔ)庫(kù)中刪除,但仍在本地“remotes / <name>”中可用。
使用--dry-run
選項(xiàng),報(bào)告將修改哪些分支,但不實(shí)際修改它們。
update
按遙控器 <group> 的定義,獲取存儲(chǔ)庫(kù)中一組指定遙控器的更新。如果未在命令行中指定命名組,則將使用配置參數(shù) remotes.default ; 如果沒(méi)有定義 remotes.default ,那么沒(méi)有配置參數(shù) remote. <name> .skipDefaultUpdate 設(shè)置為 true 的所有遙控器都將被更新。(請(qǐng)參閱 git-config [1])。
使用--prune
選項(xiàng),修剪所有更新的遙控器。
遠(yuǎn)程配置使用remote.origin.url
和remote.origin.fetch
配置變量來(lái)實(shí)現(xiàn)。(請(qǐng)參閱 git-config [1])。
添加一個(gè)新的遠(yuǎn)程,獲取并簽出一個(gè)分支 $ git remote origin $ git branch -r origin / HEAD - > origin / master origin / master $ git remote add staging git://git.kernel.org/。 ../gregkh/staging.git $ git 遠(yuǎn)程原點(diǎn)暫存 $ git fetch staging ...從git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging *新的分支主控 - > staging / staging-next $ git branch -r origin / HEAD - > origin / master origin / master staging / master staging / master staging / master staging / master staging / master staging / staging-linus staging / staging-next $ git checkout -b臨時(shí)分段/主...
模仿git clone
但只追蹤選定的分支
$ mkdir project.git $ cd project.git $ git init $ git remote add -f -t master -m master origin git://example.com/git.git/ $ git merge origin
git-fetch [1] git-branch [1] git-config [1]