禁用有关分离的 HEAD 的警告
Disable warning about detached HEAD
在 git 中,如果您直接签出一个提交,您会收到一个以以下内容开头的大警告:
"You are in 'detached HEAD' state. You can look around ..."
没关系 - 我打算处于分离的 HEAD 状态。但是我在脚本中使用它,我不想在输出日志中出现这个警告,但我确实想要正常输出。
我的 "ugly" 解决方法现在是 运行 两次相同的命令,第一次使用 -q 隐藏警告,再一次获得正常输出: HEAD is now at deadbeef... Message
因为警告只打印一次。
是否可以禁用警告以便我可以避免解决方法或解析输出?
您拥有此任务的配置:
通过将配置值设置为 false 来关闭所需的消息:
# turn the detached message off
git config --global advice.detachedHead false
detachedHead
Advice shown when you used git-checkout(1) to move to the detach HEAD state, to instruct how to create a local branch after the fact.
advice.*
These variables control various optional help messages designed to aid new users. All advice.* variables default to true, and you can tell Git that you do not need help by setting these to false:
您可以在建议后设置以下任何一项:
git config --global advice.<...>
pushUpdateRejected
Set this variable to false if you want to disable
pushNonFFCurrent,
pushNonFFMatching,
pushAlreadyExists,
pushFetchFirst, and
pushNeedsForce simultaneously.
pushNonFFCurrent
Advice shown when git-push(1) fails due to a non-fast-forward update
to the current branch.
pushNonFFMatching
Advice shown when you ran git-push(1) and pushed matching refs
explicitly (i.e. you used :, or specified a refspec that isn’t your
current branch) and it resulted in a non-fast-forward error.
pushAlreadyExists
Shown when git-push(1) rejects an update that does not qualify
for fast-forwarding (e.g., a tag.)
pushFetchFirst
Shown when git-push(1) rejects an update that tries to overwrite a
remote ref that points at an object we do not have.
pushNeedsForce
Shown when git-push(1) rejects an update that tries to overwrite a
remote ref that points at an object that is not a commit-ish, or make
the remote ref point at an object that is not a commit-ish.
statusHints
Show directions on how to proceed from the current state in the output
of git-status(1), in the template shown when writing commit messages in
git-commit(1), and in the help message shown by git-checkout(1) when
switching branch.
statusUoption
Advise to consider using the -u option to git-status(1) when the command
takes more than 2 seconds to enumerate untracked files.
commitBeforeMerge
Advice shown when git-merge(1) refuses to merge to avoid overwriting
local changes.
resolveConflict
Advice shown by various commands when conflicts prevent the operation
from being performed.
implicitIdentity
Advice on how to set your identity configuration when your information
is guessed from the system username and domain name.
detachedHead
Advice shown when you used git-checkout(1) to move to the detach HEAD
state, to instruct how to create a local branch after the fact.
amWorkDir
Advice that shows the location of the patch file when git-am(1) fails
to apply it.
rmHints
In case of failure in the output of git-rm(1), show directions on
how to proceed from the current state.
厚颜无耻地将 mjs 的评论复制到 post 作为自己的答案:
git -c advice.detachedHead=false checkout <refspec>
-c advice.detachedHead=false
参数将允许您在无需更改全局配置的情况下抑制警告。它只适用于执行的命令。 Here's the list of all advises that can be suppressed.
在 git 中,如果您直接签出一个提交,您会收到一个以以下内容开头的大警告:
"You are in 'detached HEAD' state. You can look around ..."
没关系 - 我打算处于分离的 HEAD 状态。但是我在脚本中使用它,我不想在输出日志中出现这个警告,但我确实想要正常输出。
我的 "ugly" 解决方法现在是 运行 两次相同的命令,第一次使用 -q 隐藏警告,再一次获得正常输出: HEAD is now at deadbeef... Message
因为警告只打印一次。
是否可以禁用警告以便我可以避免解决方法或解析输出?
您拥有此任务的配置:
通过将配置值设置为 false 来关闭所需的消息:
# turn the detached message off
git config --global advice.detachedHead false
detachedHead
Advice shown when you used git-checkout(1) to move to the detach HEAD state, to instruct how to create a local branch after the fact.
advice.*
These variables control various optional help messages designed to aid new users. All advice.* variables default to true, and you can tell Git that you do not need help by setting these to false:
您可以在建议后设置以下任何一项:
git config --global advice.<...>
pushUpdateRejected
Set this variable to false if you want to disable
pushNonFFCurrent,
pushNonFFMatching,
pushAlreadyExists,
pushFetchFirst, and
pushNeedsForce simultaneously.
pushNonFFCurrent
Advice shown when git-push(1) fails due to a non-fast-forward update
to the current branch.
pushNonFFMatching
Advice shown when you ran git-push(1) and pushed matching refs
explicitly (i.e. you used :, or specified a refspec that isn’t your
current branch) and it resulted in a non-fast-forward error.
pushAlreadyExists
Shown when git-push(1) rejects an update that does not qualify
for fast-forwarding (e.g., a tag.)
pushFetchFirst
Shown when git-push(1) rejects an update that tries to overwrite a
remote ref that points at an object we do not have.
pushNeedsForce
Shown when git-push(1) rejects an update that tries to overwrite a
remote ref that points at an object that is not a commit-ish, or make
the remote ref point at an object that is not a commit-ish.
statusHints
Show directions on how to proceed from the current state in the output
of git-status(1), in the template shown when writing commit messages in
git-commit(1), and in the help message shown by git-checkout(1) when
switching branch.
statusUoption
Advise to consider using the -u option to git-status(1) when the command
takes more than 2 seconds to enumerate untracked files.
commitBeforeMerge
Advice shown when git-merge(1) refuses to merge to avoid overwriting
local changes.
resolveConflict
Advice shown by various commands when conflicts prevent the operation
from being performed.
implicitIdentity
Advice on how to set your identity configuration when your information
is guessed from the system username and domain name.
detachedHead
Advice shown when you used git-checkout(1) to move to the detach HEAD
state, to instruct how to create a local branch after the fact.
amWorkDir
Advice that shows the location of the patch file when git-am(1) fails
to apply it.
rmHints
In case of failure in the output of git-rm(1), show directions on
how to proceed from the current state.
厚颜无耻地将 mjs 的评论复制到 post 作为自己的答案:
git -c advice.detachedHead=false checkout <refspec>
-c advice.detachedHead=false
参数将允许您在无需更改全局配置的情况下抑制警告。它只适用于执行的命令。 Here's the list of all advises that can be suppressed.