Skip to content

Update renaming-a-branch.md #32057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Conversation

aecoleman
Copy link
Contributor

Why:

The changes made in PR#31929 are not correct in the context that the docs describe.

The context is "After you rename a branch in a repository on GitHub, any collaborator with a local clone of the repository will need to update the clone." Based on this, the section should be presenting actions to be taken in the situation where OLD-BRANCH-NAME has been renamed to NEW-BRANCH-NAME on GitHub, but OLD-BRANCH-NAME still exists in the local clone, and still has upstream set to origin/OLD-BRANCH-NAME.

The desired end-state in this situation would be for the local clone to contain no branch named OLD-BRANCH-NAME, and one branch named NEW-BRANCH-NAME, which tracks the remote branch of the same name origin/NEW-BRANCH-NAME.

The commands listed now result in a local clone containing no branch named OLD-BRANCH-NAME, and one branch named NEW-BRANCH-NAME, which tracks the remote branch with the name origin/OLD-BRANCH-NAME, which should no longer exist.

Closes:

What's being changed (if available, include any code snippets, screenshots, or gifs):

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

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](github#31929) being merged).
Copy link

welcome bot commented Mar 12, 2024

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Mar 12, 2024
Copy link
Contributor

github-actions bot commented Mar 12, 2024

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch.md fpt
ghec
ghes@ 3.12 3.11 3.10 3.9 3.8
fpt
ghec
ghes@ 3.12 3.11 3.10 3.9 3.8

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server

@nguyenalex836 nguyenalex836 added content This issue or pull request belongs to the Docs Content team repositories Content related to repositories waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Mar 12, 2024
@nguyenalex836
Copy link
Contributor

@aecoleman Thank you for opening this PR, along with providing context! I'll get this triaged for review ✨

@nguyenalex836 nguyenalex836 self-requested a review March 13, 2024 21:35
@nguyenalex836
Copy link
Contributor

@aecoleman Thanks so much for catching this, and opening a PR with this fix! I'll update the branch and get this merged once tests are passing 🍏

@nguyenalex836 nguyenalex836 enabled auto-merge March 13, 2024 21:36
@nguyenalex836 nguyenalex836 added this pull request to the merge queue Mar 13, 2024
Merged via the queue into github:main with commit 4509e3e Mar 13, 2024
Copy link
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team repositories Content related to repositories waiting for review Issue/PR is waiting for a writer's review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants