最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

git branch --create branchname works fine, but is not documented anywhere - Stack Overflow

programmeradmin2浏览0评论

git branch branchname creates new branch "branchname", we know that.

However,

git branch --create branchname also creates new branch "branchname":

yet the latter is not documented anywhere, not even in git docs.

I usually don't trust ChatGPT, but out of the curiosity, I've asked the same question to it, and it also says, that there is no git branch --create branchname.

This is weird.

Any tips?

git branch branchname creates new branch "branchname", we know that.

However,

git branch --create branchname also creates new branch "branchname":

yet the latter is not documented anywhere, not even in git docs.

I usually don't trust ChatGPT, but out of the curiosity, I've asked the same question to it, and it also says, that there is no git branch --create branchname.

This is weird.

Any tips?

Share Improve this question asked Mar 17 at 14:32 Gii TsiklauriGii Tsiklauri 11.3k9 gold badges56 silver badges83 bronze badges 17
  • 4 It's implied to be the longest form --create-reflog, I guess? You can shorten long option names as long as it's unique – Romain Valeri Commented Mar 17 at 14:37
  • 2 "Long options may be abbreviated, as long as the abbreviation is unambiguous." (doc) – Romain Valeri Commented Mar 17 at 14:45
  • 2 @RomainValeri is correct according to my testing. (1) git branch <branch> creates a branch (2) --create-reflog is an option you can provide (3) you can shorten that option to --create or --create-r (however short as long as it is not ambigious) (4) git branch --create <branch> is the same as git branch --create-reflog <branch>. – Guildenstern Commented Mar 17 at 14:46
  • 2 @UlrichEckhardt that is exactly the question for SO, and it was answered quickly. So, you're downvoting because there is no discrete StackExchange page and I've asked it here?.. look around SO, and you'll find question way off the topic of programming that git.. weird downvotes are happening here! – Gii Tsiklauri Commented Mar 17 at 15:06
  • 2 @UlrichEckhardt It's often said in a joking tone, but seriously here, it's not a bug, it's a feature! It is documented. See the link I shared above. – Romain Valeri Commented Mar 17 at 15:11
 |  Show 12 more comments

1 Answer 1

Reset to default 5

Your git branch --create foo is assumed by git to be git branch --create-reflog foo because no other option starts with --create

As confusing as it can be to quite a lot of people, it's git's way to interpret incomplete option names.

One can abbreviate long options as long as it's unique. (doc)

发布评论

评论列表(0)

  1. 暂无评论