目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

Name

git-remote  - 管理追踪存储库的集合

概要

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>)…]

描述

管理您追踪分支的一组存储库(“远程”)。

选项

-v   --verbose

稍微详细一点,并在名称后显示远程 URL 。注意:这必须放在remote和之间subcommand

命令

没有参数,显示现有遥控器的列表。几个子命令可用于在遥控器上执行操作。

add

在 <url> 处添加一个名为 <name> 的存储库。该命令git fetch <name>然后可用于创建和更新远程跟踪分支<name> / <branch>。

使用-f选项,git fetch <name>在远程信息设置完成后立即运行。

使用--tags选项,git fetch <name>从远程存储库导入每个标记。

使用--no-tags选项,git fetch <name>不会从远程存储库导入标签。

默认情况下,只有取回分支上的标签被导入(参见 git-fetch [1])。

使用-t <branch>选项,而不是远程的默认 glob refspec 来跟踪refs/remotes/<name>/命名空间下的所有分支,将<branch>创建仅用于跟踪的 refspec 。您可以给-t <branch>多个分支追踪多个分支,而无需抓取所有分支。

使用-m <master>选项,符号引用refs/remotes/<name>/HEAD被设置为指向远程的<master>分支。另请参阅 set-head 命令。

当创建获取镜像时--mirror=fetch,参考将不会存储在refs/remotes/命名空间中,而是refs/将远程中的所有内容直接镜像到refs/本地存储库中。这个选项在裸存储库中才有意义,因为提取会覆盖任何本地提交。

当创建一个推式镜像时--mirror=push,它git push总是表现得好像--mirror被传递一样。

rename

将名为 <old> 的远程重命名为 <new> 。远程的所有远程跟踪分支和配置设置都会更新。

如果 <old> 和 <new> 相同,并且 <old> 是$GIT_DIR/remotes或者下的文件$GIT_DIR/branches,则将远程转换为配置文件格式。

remove   rm

删除名为 <name> 的远程。远程的所有远程跟踪分支和配置设置均被删除。

set-head

设置或删除refs/remotes/<name>/HEAD指定远程的默认分支(即 symbolic-ref 的目标)。有一个远程的默认分支不是必需的,但允许指定远程的名称来代替特定的分支。例如,如果默认分支for origin设置为master,则origin可以在通常指定的任何位置指定origin/master

使用-d--delete,符号 ref refs/remotes/<name>/HEAD被删除。

使用-a--auto,远程被查询来确定它HEAD,然后 symbolic-ref  refs/remotes/<name>/HEAD被设置为同一分支。例如,如果远程HEAD正指向nextgit remote set-head origin -a”将设置符号 -REF refs/remotes/origin/HEADrefs/remotes/origin/next。这只有在refs/remotes/origin/next已经存在的情况下才有效; 如果不是,它必须先取得。

用于显式<branch>设置符号引用refs/remotes/<name>/HEAD。例如,“GIT 中远程设置头原点主”将设置符号 -REF refs/remotes/origin/HEADrefs/remotes/origin/master。这只有在refs/remotes/origin/master已经存在的情况下才有效; 如果不是,它必须先取得。

set-branches

更改已命名远程所跟踪分支的列表。这可以用于在远程初始设置后跟踪可用远程分支的一个子集。

指定的分支将被解释为与命令行中的-t选项一起指定git remote add

随着--add的,而不是替换当前跟踪的分支列表,添加到列表中。

get-url

检索远程的 URL 。这里的配置insteadOfpushInsteadOf扩展。默认情况下,仅列出第一个 URL 。

使用--push,查询推送 URL 而不是获取 URL 。

--all,远程的所有 URL 将被列出。

set-url

更改远程的 URL 。为匹配 regex <oldurl> 的远程 <name> 设置第一个 URL(如果没有给出 <oldurl> ,则为第一个 URL )为 <newurl> 。如果 <oldurl> 与任何 URL 都不匹配,则会发生错误并且没有任何更改。

使用时--push,推送网址将被操纵,而不是抓取网址。

随着--add,而不是改变现有的 URL ,新的 URL 添加。

--delete,而不是改变现有的 URL ,所有匹配正则表达式 <URL> URL 被用于远程 <name> 删除。试图删除所有非推送网址是一个错误。

请注意,即使可以设置不同的推送网址和提取网址,仍必须引用相同的地方。您推送到推送网址的内容应该是您立即从提取网址获取的内容。如果您试图从一个地方(例如上游)获取数据并推送到另一个地方(例如您的发布存储库),请使用两个单独的遥控器。

show

给出关于远程 <name> 的一些信息。

通过-n选项,远程头不首先被查询git ls-remote <name>; 取而代之的是使用缓存的信息。

prune

删除 <name> 下的所有陈旧的远程追踪分支。这些陈旧的分支已从 <name> 引用的远程存储库中删除,但仍在本地“remotes / <name>”中可用。

使用--dry-run选项,报告将修改哪些分支,但不实际修改它们。

update

按遥控器 <group> 的定义,获取存储库中一组指定遥控器的更新。如果未在命令行中指定命名组,则将使用配置参数 remotes.default ; 如果没有定义 remotes.default ,那么没有配置参数 remote. <name> .skipDefaultUpdate 设置为 true 的所有遥控器都将被更新。(请参阅 git-config [1])。

使用--prune选项,修剪所有更新的遥控器。

讨论

远程配置使用remote.origin.urlremote.origin.fetch配置变量来实现。(请参阅 git-config [1])。

例子

  • 添加一个新的远程,获取并签出一个分支 $ git remote origin $ git branch -r origin / HEAD  - > origin / master origin / master $ git remote add staging git://git.kernel.org/。 ../gregkh/staging.git $ git 远程原点暂存 $ 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临时分段/主...

  • 模仿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]

上一篇: 下一篇: