Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.43.1 → 2.44.0 no changes
- 2.43.0 11/20/23
- 2.39.1 → 2.42.1 no changes
- 2.39.0 12/12/22
概述
git symbolic-ref [-m <原因>] <名称> <引用> git symbolic-ref [-q] [--short] [--no-recurse] <名称> git symbolic-ref --delete [-q] <名称>
描述
Given one argument, reads which branch head the given symbolic ref refers to and outputs its path, relative to the .git/
directory. Typically you would give HEAD
as the <name> argument to see which branch your working tree is on.
在给定两个参数的情况下,创建或更新符号引用 <名称> 以指向给定的分支 <引用>。
给定 --delete
和一个附加参数,删除给定的符号引用。
A symbolic ref is a regular file that stores a string that begins with ref: refs/
. For example, your .git/HEAD
is a regular file whose content is ref: refs/heads/master
.
选项
- -d
- --delete
-
删除符号引用 <名称>。
- -q
- --quiet
-
如果 <名称> 不是符号引用,而是分离的 HEAD,则不会发出错误信息;而是以非零状态静默退出。
- --short
-
将 <名称> 的值作为符号引用显示时,请尽量缩短该值,例如将
refs/heads/master
改为master
。 - --recurse
- --no-recurse
-
When showing the value of <name> as a symbolic ref, if <name> refers to another symbolic ref, follow such a chain of symbolic refs until the result no longer points at a symbolic ref (
--recurse
, which is the default).--no-recurse
stops after dereferencing only a single level of symbolic ref. - -m
-
Update the reflog for <name> with <reason>. This is valid only when creating or updating a symbolic ref.
注释
In the past, .git/HEAD
was a symbolic link pointing at refs/heads/master
. When we wanted to switch to another branch, we did ln -sf refs/heads/newbranch .git/HEAD
, and when we wanted to find out which branch we are on, we did readlink .git/HEAD
. But symbolic links are not entirely portable, so they are now deprecated and symbolic refs (as described above) are used by default.
如果符号引用的内容打印正确,git symbolic-ref 将以状态 0 退出;如果请求的名称不是符号引用,则以状态 1 退出;如果出现其他错误,则以 128 退出。
GIT
属于 git[1] 文档