项目作者: c0riolis

项目描述 :
A tool that helps you to restore commits erased by a force push
高级语言: Python
项目地址: git://github.com/c0riolis/tifu.git
创建时间: 2017-01-15T17:35:01Z
项目社区:https://github.com/c0riolis/tifu

开源协议:

下载


TIFU (Today I Fucked Up)

Overview

TIFU is a tool that helps to restore commits erased by a force push on
Github, Gitlab and Bitbucket.

Requirements

Python 3.5+

Installation

Just clone, install dependencies, and you’re ready to go!

  1. git clone git@github.com:c0riolis/tifu.git
  2. cd tifu
  3. pip3 install -r requirements.txt --user
  4. ./tifu.py --help

How to use it?

The simplest way to run the tool is to launch it with a remote as argument:

  1. ./tifu.py git@github.com:namespace/project.git

Or

  1. ./tifu.py https://github.com/namespace/project.git

It will automatically infer the API, repository name and hostname to use.

If you want to run it on your own instance of Gitlab for example, this will
fail since the tool can’t determine which API to use. Just specify it:

  1. ./tifu.py git@mydomain.com:namespace/project.git --api gitlab

This is equivalent to the following command:

  1. ./tifu.py --api gitlab --host mydomain.com --repo namespace/project

You can also just connect to a specific API and select the repository
interactively:

  1. ./tifu.py --api bitbucket

Which works for your own instances as well:

  1. ./tifu.py --api github --host mydomain.com

Usage

  1. usage: tifu.py [-h] [-a] [--host HOST] [-n REPO] [remote]
  2. positional arguments:
  3. remote git remote
  4. optional arguments:
  5. -h, --help show this help message and exit
  6. -a , --api API to use (github, gitlab, bitbucket)
  7. --host HOST server hostname
  8. -r REPO, --repo REPO repository name (namespace/project)

How does it work?

Git repository managers are usually using event systems to build users’ threads.
These events are accessible via APIs and are providing various pieces of information.

In this case, we are using events generated on push to get the ID of the
previous HEAD and create a branch pointing to it.

Old HEAD’s objects are usually still available since they are not removed until
the repository is garbage collected on the server side.