Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GitHub garbage collect dangling commits referenced in pull requests?

Tags:

git

branch

github

The following situation arises from time to time…

I git checkout -b experiment, commit some experimental changes, and open a pull request. After some discussion, the pull request is rejected.

If I were now to delete the remote branch, would this render the diff inaccessible at some point, or does GitHub ensure that commits which appear in pull requests are not garbage collected even if they don't appear on any branch?

I would like to delete dead branches, but only if doing so will not diminish the historical value of rejected pull requests.

like image 615
davidchambers Avatar asked Mar 07 '13 02:03

davidchambers


People also ask

How do I remove a last commit from a Github pull request?

Step-1: Make sure your working directory is clean ( commit or stash your current changes). Step-2: One can use the git-rebase command to easily make changes to one's history. After running the git rebase command you get the following in your $EDITOR: Step-3: Replace pick with drop to “drop” the commit.

What happens if I close pull request github?

You may choose to close a pull request without merging it into the upstream branch. This can be handy if the changes proposed in the branch are no longer needed, or if another solution has been proposed in another branch.

Can a pull request contain multiple commits?

Yes, it will. This includes merge commits, by the way, so if a different branch than the target branch of the pull request is merged in to the branch, then the merge commit and both of its parent chains of commits (from both branches) will become part of the PR.


1 Answers

No, they will not be gc's because they're not wholly unreferenced even if you delete your branch.

Github creates a branch (actually, two) for every pull request. They're in a non-default namespace so you dont usually get them when you pull (or fetch) from the repo.

To see how this looks in practice, do a git ls-remote <REMOTE>, where <REMOTE> is either the name of a remote (if it's one your repo knows) or the URL (it doesn't need to be git remote added for this to work). This remote should have some pull requests, or you won't be able to see what I mean.

This will list all refs on the remote (all branches and tags), and you will see some refs like refs/pull/<number>/head and refs/pull/<number>/merge. Those refer to the latest commit in the PR and the commit at which it was merged in, respectively.

like image 143
Nevik Rehnel Avatar answered Sep 26 '22 14:09

Nevik Rehnel