我有一个github回购,我正在网站上工作,我不知道怎么做命令行的东西。
所以我有一个分支我也提交了。我看到它可以删除。这很好。我总是做小单元测试,只是想删除它。所以,如果我删除了一个分支,那么它的所有痕迹和历史都消失了吗?
答案 0 :(得分:2)
如果您不再拥有本地仓库(意味着您无法通过本地git reflog获取已删除的分支并将其推回GitHub),您仍然可以检索(在有限时间内,默认为90天) ),你从GitHub回购邮件中删除的分支。
请参阅GitHub Events API 那些事件在时间上是有限的,所以"它的所有痕迹和历史都消失了?":是的,最终。
curl https://api.github.com/repos/<user>/<repo>/events
正如this blog post中所述,您将获得一个JSON有效负载,其中包含您所做的任何push event,包括您的旧分支:
"id": "1970551769",
"type": "PushEvent",
"actor": {
"id": 563541,
"login": "<user>",
"gravatar_id": "<id>",
"url": "https://api.github.com/users/<user>",
"avatar_url": "<url>"
},
"repo": {
"id": 9652839,
"name": "<user>/<repo>",
"url": "https://api.github.com/repos/<user>/<repo>"
},
"payload": {
"push_id": 303837533,
"size": 1,
"distinct_size": 1,
"ref": "refs/heads/<branch>", <============================
"head": "a973ddd28d599c9ba128de56182f8769d2b9843b",
"before": "4ef3d74316c04c892d17250f0ba251b328274e5f",
"commits": [
{
"sha": "384f275933d5b762cdb27175aeff1263a8a7b7f7",
"author": {
"email": "<email>",
"name": "<author>"
},
"message": "<commit message>",
"distinct": true,
"url": "https://api.github.com/repos/<user>/<repo>/commits/384f275933d5b762cdb27175aeff1263a8a7b7f7"
}
]
},
"public": false,
"created_at": "2014-02-06T14:05:17Z"
}
然后,您可以fetch, using that specific commit&#39; a973ddd28d599c9ba128de56182f8769d2b9843b
&#39;,在本地创建分支并将其推回GitHub!
git fetch origin a973ddd28d599c9ba128de56182f8769d2b9843b:refs/remotes/origin/yourOldBranch
git checkout -b yourOldBranch
git push