Linux command
git-check-ref-format 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Check if ref name is valid
git check-ref-format [refs/heads/branch]
Check branch name
git check-ref-format --branch [name]
Normalize refname
git check-ref-format --normalize [refs/heads/branch]
说明
git check-ref-format validates and normalizes Git reference names according to strict naming rules. This ensures branch and tag names are portable across filesystems and don't conflict with Git internals. Reference names must not contain spaces, tildes, carets, colons, question marks, asterisks, or brackets. They cannot begin or end with slashes, contain consecutive slashes, or end with .lock. Components between slashes cannot begin with dots. These rules prevent filesystem conflicts and shell interpretation issues. The command is used programmatically by scripts creating branches or tags to validate user input before attempting operations. Normalization removes redundant slashes and ensures consistent formatting. The --branch option interprets the name as a branch shorthand, expanding it to refs/heads/ format.
参数
- --branch
- Check as branch name.
- --normalize
- Normalize refname.
- --allow-onelevel
- Allow single-level refs (refnames without multiple `/`-separated components).
- --no-allow-onelevel
- Require hierarchical refs (default).
- --refspec-pattern
- Interpret refname as a refspec pattern, allowing a single `*` wildcard.
FAQ
What is the git-check-ref-format command used for?
git check-ref-format validates and normalizes Git reference names according to strict naming rules. This ensures branch and tag names are portable across filesystems and don't conflict with Git internals. Reference names must not contain spaces, tildes, carets, colons, question marks, asterisks, or brackets. They cannot begin or end with slashes, contain consecutive slashes, or end with .lock. Components between slashes cannot begin with dots. These rules prevent filesystem conflicts and shell interpretation issues. The command is used programmatically by scripts creating branches or tags to validate user input before attempting operations. Normalization removes redundant slashes and ensures consistent formatting. The --branch option interprets the name as a branch shorthand, expanding it to refs/heads/ format.
How do I run a basic git-check-ref-format example?
Run `git check-ref-format [refs/heads/branch]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --branch do in git-check-ref-format?
Check as branch name.