Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

git - Does GitHub garbage collect dangling commits referenced in pull requests?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...