git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Mention default oldbranch in git-branch doc

From
CGClarence Sparr Risher via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 30, 2023, 00:24 UTC
Message-ID
<pull.1613.git.git.1701303891791.gitgitgadget@gmail.com>
From: "Clarence \"Sparr\" Risher" <sparr0@gmail.com>

`git branch -m` has an optional first argument, the branch to rename. If omitted, it defaults to the current branch. This behavior is not currently described in the documentation. While it can be determined relatively easily through experimentation, and less so through viewing the source code (builtin/branch.c:897), it is not obvious what such a command will do when encountered in a less interactive context.

This patch adds one sentence to the git-branch documentation, with wording based on another optional argument described earlier in the same doc.

The same behavior applies to -M, -c, and -C, which are all covered by this same section of the documentation.

Signed-off-by: Clarence Risher <clarence@kira-learning.com>
Signed-off-by: Clarence "Sparr" Risher <sparr0@gmail.com>
---
    Mention default oldbranch in git-branch doc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1613%2Fsparr%2Fdoc_branch_rename_one_param-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1613/sparr/doc_branch_rename_one_param-v1
Pull-Request: https://github.com/git/git/pull/1613
 Documentation/git-branch.txt | 1 +
 1 file changed, 1 insertion(+)
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index 4395aa93543..affed1b17a4 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -73,6 +73,7 @@ overridden by using the `--track` and `--no-track` options, and
 changed later using `git branch --set-upstream-to`.
 
 With a `-m` or `-M` option, <oldbranch> will be renamed to <newbranch>.
+If the <oldbranch> argument is missing it defaults to the current branch.
 If <oldbranch> had a corresponding reflog, it is renamed to match
 <newbranch>, and a reflog entry is created to remember the branch
 renaming. If <newbranch> exists, -M must be used to force the rename

base-commit: 564d0252ca632e0264ed670534a51d18a689ef5d
-- 
gitgitgadget
Next: Rubén Justo
Message 1 of 2 in “Mention default oldbranch in git-branch doc”
  1. Mention default oldbranch in git-branch docClarence Sparr Risher via GitGitGadget, Nov 30, 2023
  2. Rubén JustoDec 1, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.