Github甚至在完成提交之后删除了分支? [英] Github delete branch even after made commits to it?

查看:169
本文介绍了Github甚至在完成提交之后删除了分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个github回购站,我在网站上工作,我不知道如何去做命令行的东西。



所以我有一个分支也承诺。我发现它可以被删除。这真是太好了。我经常做小单元测试,只想删除它。所以如果我删除了一个分支,它的所有痕迹和历史就消失了吗? 解决方案

如果您没有本地回购(即不能通过本地git reflog获取已删除的分支并将其推回到GitHub),您仍然可以检索(限制时间,默认为90天),从GitHub回购本身删除分支。



请参阅 GitHub Events API
这些事件在时间上是有限的,所以所有的痕迹和它的历史都消失了吗?:是的,最终。

  curl https://api.github.com/repos/<user>/<repo>/events 

这篇博文,你将得到一个JSON负载,其中将包含任何推送活动,包括您的旧分支:

 id:1970551769,
type:PushEvent,
actor:{
id:563541,
login:< ;用户>,
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 :a973ddd28d599c9​​ba128de56182f8769d2b9843b,
before:4ef3d74316c04c892d17250f0ba251b328274e5f,
commitits:[
{
sha:384f275933d5b762cdb27175aeff1263a8a7b7f7,
author :{
email:< email>,
name:< author>
},
message:< commit message>,
distinct:true,
url:https://api.github.com / repos /< user> /< repo> / commitits / 384f275933d5b762cdb27175aeff1263a8a7b7f7
}
]
},
public:false,
created_at :2014-02-06T14:05:17Z
}

然后,使用特定的提交' a973ddd28d599c9​​ba128de56182f8769d2b9843b ',在本地创建一个分支并将其推回到GitHub!

  git fetch origin a973ddd28d599c9​​ba128de56182f8769d2b9843b:refs / remotes / origin / yourOldBranch 
git checkout - b yourOldBranch
git push


I have a github repo and I am working on the site, I don't know how to do command line stuff.

So I have a branch I made commits too. And I see it can be deleted. This is kind of nice. I always do small unit tests and just want to delete it. So if I do delete a branch is all traces and history of it gone?

解决方案

If you don't have a local repo anymore (meaning you cannot get your deleted branch through the local git reflog and push it back to GitHub), you still can retrieve (for a limited time, 90 days by default), your deleted branch from the GitHub repo itself.

See the GitHub Events API.
Those events are limited in time, so "all traces and history of it gone?": yes, eventually.

curl https://api.github.com/repos/<user>/<repo>/events

As described in this blog post, you will get a JSON payload which will include any push event you ever made, including your old branch:

    "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"
}

You can then fetch, using that specific commit 'a973ddd28d599c9ba128de56182f8769d2b9843b', make a branch locally and push it back to GitHub!

git fetch origin a973ddd28d599c9ba128de56182f8769d2b9843b:refs/remotes/origin/yourOldBranch
git checkout -b yourOldBranch
git push

这篇关于Github甚至在完成提交之后删除了分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆