ディレクトリ 検索
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
テキスト

名称

git-check-ref-format  - 确保引用名称格式正确

概要

git check-ref-format [--normalize]       [--[no-]allow-onelevel] [--refspec-pattern]       <refname>git check-ref-format --branch <branchname-shorthand>

描述

检查给定refname是否可接受,如果不是,则退出非零状态。

Git 使用引用来指定分支和标签。分支头存储在refs/heads层次结构中,而标记存储在refs/tagsref命名空间的层次结构中(通常位于$GIT_DIR/refs/heads$GIT_DIR/refs/tags目录中,或者作为$GIT_DIR/packed-refs文件中的条目,如果引用被git gc打包)。

Git 对引用的命名方式施加了以下规则:

1. 它们可以包括/用于分层(目录)分组的斜杠,但没有斜线不以.开始或以.lock序列结束。

2. 它们必须包含至少一个/。这强制类似的heads/tags/等存在,但是实际名称不受限制。如果使用--allow-onelevel选项,则放弃该规则。

3. 他们不能在..任何地方有两个连续的点。

4. 它们不能具有任何位置的 ASCII 控制字符(即,其值低于\ 040或\ 177DEL的字节),空格,波浪形符号~,插入符号^或冒号:

5. 他们不能在任何地方出现问号?,星号*或开口支架[。有关--refspec-pattern此规则的例外情况,请参阅下面的选项。

6. 它们不能以斜杠开始或结束,/或者包含多个连续的斜杠(请参阅--normalize下面的选项以了解此规则的例外情况)

7. 它们不能以点.结束。

8. 他们不能包含一个@{序列。

9. 他们不能是单个@角色。

10. 他们不能包含一个\

这些规则使得基于 shell 脚本的工具可以很容易地解析引用名称,当引用名称被不加引号(错误地)使用引用名称时,通过 shell 进行路径名扩展,并且还避免了某些引用名称表达式中的歧义(请参阅gitrevisions [7]):

1. 像在ref1..ref2中经常使用双点..,在某些情况下,这个表示意味着^ref1 ref2(即不在ref1和在ref2)。

2. 腭化符号~字符和补注号^字符被用于引入后缀nth parentpeel onion操作。

3. 冒号:被用来在srcref:dstref中表示“ 在 srccref 的值中使用 srcref的值并将其存储在 dstref 中”在读取和推送操作中。它也可以用来选择一个特定的对象,比如 'git cat-file':“git cat-file blob v1.3.3:refs.c”。

4. at-open-brace @{被用作访问 reflog 条目的符号。

通过--branch选项,它可以扩展“以前的分支语法” @{-n}。例如,@{-1}是一种引用最后一个分支的方法。这个选项应该被porcelains用来在任何需要分支名称的地方接受这个语法,所以他们可以像你输入分支名称一样行事。

选项

--no-allow-onelevel

控制是否接受单层refnames(即不包含多个/分离组件的refnames )。默认是--no-allow-onelevel

--refspec-pattern

将<refname>解释为refspec的参考名称模式(与远程存储库一起使用)。如果这个选项被激活,<refname>允许含有单个*中操作的Refspec(例如,foo/bar*/bazfoo/bar*baz/而不是foo/bar*/baz*)。

--normalize

refname通过删除任何前导斜杠(/)字符并将名称组件之间相邻斜线的运行折叠为单斜杠来标准化。如果标准化的 refname 有效,那么将其输出到标准输出并以状态0退出,否则以非零状态退出。(--print是拼写--normalize的不赞成的方式。)

示例

  • 打印上一个分支的名称:$ git check-ref-format --branch @ { -  1}

  • 确定用于新分支的参考名称:

$ ref=$(git check-ref-format --normalize "refs/heads/$newbranch")|| { echo "we do not like '$newbranch' as a branch name." >&2 ; exit 1 ; }

前の記事: 次の記事: