GithubHelp home page GithubHelp logo

deribaucourt / git-find-worktree Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

A basic tool to identify the original git commit corresponding to a working tree where the .git has been lost

License: European Union Public License 1.2

Awk 24.42% Shell 75.58%

git-find-worktree's Introduction

git-find-worktree

A basic tool to identify the original git commit corresponding to a working tree where the .git has been lost.

Unfortunately in the industry, poor practicies may lead to an original git repository losing it's history contained in the .git directory. On top of this, some modifications may be applied without keeping trace of the history. Eventually, the git history will have to be recovered, wether to get updates from upstream, or to publish the local modifications. For this, it is necessary to find which commit the local working tree originated from.

This tool aims to do just that. For each commit on a given branch from the original repository, it will compare the local working tree and report the commit ID with the least differences.

This was inspired by the following stack overflow question : git find commit from "working tree"

Dependencies

The following packages are required:

  • bash
  • git
  • awk

How to use it

  1. Clone the original repository corresponding to the working tree.

$ git clone $ cd

  1. Erase all contents except the .git and overwrite with your working tree.

$ rm -rf * $ cp -r /* . $ git add -a

  1. Run the script with the name of the branch you want to examine.

$ /git-find-worktree.sh master

You will get results like this:

Foud a closer commit: fe15f9983b180a927681260a4c4bb6c878595a1f with 335122 differences
Foud a closer commit: 329665d68b17479ccd11fa60479c9c7a8b2355a8 with 266970 differences
Foud a closer commit: 30a1502c5a62b5cc411bb9bfb2b6706b9e39f6d6 with 266940 differences
Foud a closer commit: 2e18f8f8180743d311b2690a275de3a3b9c0a140 with 266939 differences
Foud a closer commit: 8f02ab63160ddd234a8a0c028696be23388cd61e with 266850 differences

git-find-worktree's People

Contributors

deribaucourt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.