Skip to content
/ tifu Public

A tool that helps you to restore commits erased by a force push

Notifications You must be signed in to change notification settings

c0riolis/tifu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

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

How to use it?

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

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

Or

./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:

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

This is equivalent to the following command:

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

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

./tifu.py --api bitbucket

Which works for your own instances as well:

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

Usage

usage: tifu.py [-h] [-a] [--host HOST] [-n REPO] [remote]

positional arguments:
  remote                git remote

optional arguments:
  -h, --help            show this help message and exit
  -a , --api            API to use (github, gitlab, bitbucket)
  --host HOST           server hostname
  -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.

About

A tool that helps you to restore commits erased by a force push

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages