From 43d834df6f025b475215b57b8b7d64098d6f4420 Mon Sep 17 00:00:00 2001 From: Andrew Coleman <30481896+aecoleman@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:22:37 -0400 Subject: [PATCH] Update renaming-a-branch.md In the situation described, the local repository was cloned from the remote origin repository (presumably GitHub) at some point in the past before `OLD-BRANCH-NAME` had been renamed to `NEW-BRANCH-NAME` in the remote repository, GitHub. Using ``` git branch -u origin/OLD-BRANCH-NAME NEW-BRANCH-NAME ``` sets the local `NEW-BRANCH-NAME` to track the remote `origin/OLD-BRANCH-NAME`, which does not exist in the situation described (because it has been changed to `NEW-BRANCH-NAME`). The correct command for this situation is: ``` git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME ``` which is what the docs previously said (prior to [this PR](https://github.com/github/docs/pull/31929) being merged). --- .../managing-branches-in-your-repository/renaming-a-branch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch.md b/content/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch.md index 6c929f6e78e9..2e1b04267ced 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch.md @@ -43,7 +43,7 @@ From the local clone of the repository on a computer, run the following commands ```shell git branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME git fetch origin -git branch -u origin/OLD-BRANCH-NAME NEW-BRANCH-NAME +git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME git remote set-head origin -a ```