Skip to content

Document how to delete remote branches.#256

Merged
ezio-melotti merged 2 commits intopython:masterfrom
ezio-melotti:delete-remote-branches
Sep 4, 2017
Merged

Document how to delete remote branches.#256
ezio-melotti merged 2 commits intopython:masterfrom
ezio-melotti:delete-remote-branches

Conversation

@ezio-melotti
Copy link
Copy Markdown
Member

The devguide didn't seem to document how to delete remote branches.
I documented it and added a few links around.

To delete a branch that you no longer need::
To delete a **local** branch that you no longer need::

$ git branch -D <branch-name>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git branch supports both -D and -d (they are equivalent).
git push only supports -d.

Since it's easier to type and to remember, I switched it to the lowercase form.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WWWWWHAT. They are not equivalent. git branch -d <branch_name> don't remove the branch and complains if the branch wasn't merged in another branch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm they're not quite the same.
-D is the "force" option.
If a PR is not yet merged, -d will not delete the branch I think, you'll get an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I misread the man page. Apparently -D is equivalent to -d --force which deletes the branch even if it hasn't been merged. Since usually branches get deleted after they have been merged, do you think it's ok to suggest -d anyway? I can also add a note about deleting unmerged branches using -D.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given up understanding when git will accept -d; it usually won't when I think it should. I always use -D.

Copy link
Copy Markdown
Member

@Mariatta Mariatta Sep 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I ended up using the uppercase -D all the time because I don't want to deal with the error message :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'll revert the change to the uppercase -D then.

pullrequest.rst Outdated

After your PR has been accepted and merged, you can :ref:`delete the branch <deleting_branches>`::

git branch -d MY_BRANCH_NAME # delete local branch
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ALL_CAPS_VARIABLE is inconsistent with the <variable> used elsewhere, but it's unrelated to this PR so I didn't change it.

@ezio-melotti ezio-melotti added the type-feature Additions; New content or section needed label Sep 4, 2017
pullrequest.rst Outdated
#. Review and address `comments on your Pull Request`_

#. When your changes are merged, celebrate contributing to CPython! :)
#. When your changes are merged, you can delete the branch
Copy link
Copy Markdown
Member

@Mariatta Mariatta Sep 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should link to the deleting branches section.

Copy link
Copy Markdown
Member

@Mariatta Mariatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe still better to use Uppercase -D when deleting branch.. to simplify things.

Copy link
Copy Markdown
Member

@Mariatta Mariatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks @ezio-melotti :)

@warsaw
Copy link
Copy Markdown
Member

warsaw commented Sep 4, 2017

FWIW, it has to be -D because we squash merge. Your local git has no way to know that your local revisions have been committed, so -d won't work. (It would if we didn't squash merge.)

Copy link
Copy Markdown
Member

@zware zware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ezio-melotti ezio-melotti merged commit 686ffd0 into python:master Sep 4, 2017
@ezio-melotti
Copy link
Copy Markdown
Member Author

Thanks everyone for the reviews!

@ezio-melotti ezio-melotti deleted the delete-remote-branches branch September 6, 2017 18:52
AA-Turner pushed a commit to AA-Turner/devguide that referenced this pull request Jun 17, 2022
* Document how to delete remote branches.

* Address review comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature Additions; New content or section needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants