什么是-b";代表“in”;git签出-b*在此处插入“功能”分支*“;?
我最近成为了我所在组织的一名开发人员,我一直在试图回答“我为什么这么做?”这些问题,这些问题是我在浏览我们的开发人员文档时一直在问自己的。其中一个问题是这篇文章的标题 为了创建一个特征分支,给出了命令“gitco-b insert_feature_branch_here”。出于某种原因,“co”对我不起作用。我了解到这是“checkout”,用于查看另一个分支,但我不明白-b是什么意思。根据上下文线索,“-b”似乎是“git分支”和“git签出”的复合标志。不过,是这样吗 有人对此有意见吗?我已经搜索过了,没有发现任何东西。为了避免这些简单的问题在将来被问到,是否有人知道在线文档可供参考,以了解未来某些标志的含义 提前感谢,,什么是-b";代表“in”;git签出-b*在此处插入“功能”分支*“;?,git,Git,我最近成为了我所在组织的一名开发人员,我一直在试图回答“我为什么这么做?”这些问题,这些问题是我在浏览我们的开发人员文档时一直在问自己的。其中一个问题是这篇文章的标题 为了创建一个特征分支,给出了命令“gitco-b insert_feature_branch_here”。出于某种原因,“co”对我不起作用。我了解到这是“checkout”,用于查看另一个分支,但我不明白-b是什么意思。根据上下文线索,“-b”似乎是“git分支”和“git签出”的复合标志。不过,是这样吗 有人对此有意见吗?我已
Alex这意味着,它将创建分支,然后将其签出 请参见以下内容中的: 指定-b将导致创建一个新分支,就像调用并签出git分支一样
您可以将
-b
视为要在新分支中直接开始工作时使用的标志。它首先创建新分支,然后自动将您签出到该分支,以便您可以开始在该分支内工作 首先,恭喜你!
在我看来,作为一名开发人员,你可以做的最重要的事情之一就是不断地问自己“我为什么要这么做?”
请记住,当您编写git checkout-b
时,每个单词都会被独立地解析和处理,因此从git开始,它告诉控制台从系统路径加载git程序,然后,每个单词都会被输入git程序
快速git--help
允许我们查看可以输入哪些类型的命令
git --help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
您将看到一个包含签出可以接收的所有参数的手册页[分支名称,如何解决冲突,如果您想强制签出,等等],这里重要的是,这些参数可以以不同的顺序输入,那么git如何知道哪个词表示分支名称,哪个词表示其他参数呢?
通过使用标志,例如-b
!
假设您输入:
git checkout --help
git checkout -b mycoolbranch -f
git知道在-b
之后,每个单词都将成为分支名称的一部分,直到找到另一个参数(或行尾)
所以基本上这就是-b
(或许多命令工具中的任何其他标志)的工作方式
如果您陷入困境,--help
始终是一个很好的起点。
快乐编码 可能重复感谢您的反馈!!我将开始更频繁地合并--help程序:)