[PATCH] Modified the default git help message to be grouped by topic

Subsystems: the rest

STALE3732d

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] Modified the default git help message to be grouped by topic

From: Scott Chacon <hidden>
Date: 2016-06-15 22:45:42

It's difficult to process 21 commands (which is what is output
by default for git when no command is given).  I've re-grouped
them into 4 groups of 5 or 6 commands each, which I think is
clearer and easier for new users to process.

As discussed at the GitTogether.

Signed-off-by: Scott Chacon <redacted>
---

This makes the 'git' (with no arguments) command look like this:
http://gist.github.com/20553

This won't automatically update with the common-commands.txt file,
but I think it is easier to parse for the command you may be looking
for.

 builtin-help.c |   42 +++++++++++++++++++++++++++++-------------
 1 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/builtin-help.c b/builtin-help.c
index f076efa..562d5d1 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -277,19 +277,35 @@ static struct cmdnames main_cmds, other_cmds;
 
 void list_common_cmds_help(void)
 {
-	int i, longest = 0;
-
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		if (longest < strlen(common_cmds[i].name))
-			longest = strlen(common_cmds[i].name);
-	}
-
-	puts("The most commonly used git commands are:");
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
-		puts(common_cmds[i].help);
-	}
+	puts("The most commonly used git commands are:\n\
+\n\
+Basic Commands\n\
+  init       Create an empty git repository or reinitialize an existing one\n\
+  add        Add file contents to the staging area\n\
+  status     Show the working tree and staging area status\n\
+  commit     Record changes in the staging area to the repository\n\
+  rm         Remove files from the working tree and from the index\n\
+  mv         Move or rename a file, a directory, or a symlink\n\
+\n\
+History Commands\n\
+  log        Show commit log history\n\
+  diff       Show changes between commits, commit and working tree, etc\n\
+  grep       Print lines in git tracked files matching a pattern\n\
+  reset      Reset current HEAD to the specified state\n\
+  show       Show various types of objects\n\
+\n\
+Branch Commands\n\
+  checkout   Checkout a branch or paths to the working tree\n\
+  branch     List, create, or delete branches\n\
+  merge      Join two or more development histories together\n\
+  rebase     Apply changes introduced in one branch onto another\n\
+  tag        Create, list, delete or verify a tag object signed with GPG\n\
+\n\
+Remote Commands\n\
+  clone      Clone a repository into a new directory\n\
+  fetch      Download objects and refs from another repository\n\
+  pull       Fetch from and merge with another repository or a local branch\n\
+  push       Update remote refs along with associated objects");
 }
 
 static int is_git_command(const char *s)
-- 
1.6.0.8.gc9c8

Re: [PATCH] Modified the default git help message to be grouped by topic

From: Jeff King <hidden>
Date: 2016-06-15 22:45:43

On Mon, Dec 01, 2008 at 09:30:37AM -0800, Scott Chacon wrote:
It's difficult to process 21 commands (which is what is output
by default for git when no command is given).  I've re-grouped
them into 4 groups of 5 or 6 commands each, which I think is
clearer and easier for new users to process.
I like it (and I think the categorizations look reasonable, which is
something that I recall caused some discussion at the GitTogether).

The only downside I see is that we're now >24 lines.
This won't automatically update with the common-commands.txt file,
but I think it is easier to parse for the command you may be looking
for.
Personally, I don't see a big problem. This is not a list that should
change very frequently, and there is extra information here that would
be annoying to encode in the list. But since the "common" flag in
command-list.txt and the common-cmds.h file would no longer be used,
they should probably be removed.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help