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.2k views
in Technique[技术] by (71.8m points)

git - For how long can you restore/recover a deleted branch on GitHub?

This is not a question on how to restore lost branches in Github, but rather how long you have to restore a deleted branch through the following user case story:

Within a pull request (often used as a place for code review) the branch can be merged and then deleted, all in the github GUI. Should you choose to delete it, you are given the option with a bold and underlined word, to "restore" the branch.

I suspect this option has a time limit and that github doesn't keep this available indefinitely.

Does github have a time limit on how long you can do this? If it does, what is that time limit?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

I asked GitHub Support, this was their response (emphasis mine):

We use a separate ref namespace for all Pull Requests which we use for various things including restoring the branch. Since we keep those [Pull Request] refs indefinitely, there's no time limit on restoring a branch.

You can see these special references in your remote by using the following:

$ git ls-remote | grep pull
From [email protected]:<username>/<remote>.git
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa        refs/pull/1/head
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb        refs/pull/1/merge
cccccccccccccccccccccccccccccccccccccccc        refs/pull/2/head
dddddddddddddddddddddddddddddddddddddddd        refs/pull/2/merge

The references are namespaced under refs/pull/<pull request number>/. The head reference points at the tip of the branch that's being pull requested, i.e. the last commit on the branch. I'm not sure what the merge reference is though.


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

...