Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Predict git commit id and commit a file which contains that commit id

Tags:

git

How to do something like this:

  1. Create a with following content:

    $ cat testfile.txt
    This file will be committed with this id: 83b90a07620ef578450c40a6d38bacc42de7ad2d

  2. Commit testfile.txt
    $ git add testfile.txt
    $ git commit -m 'Thank you'

  3. Execute git log to verify predicted commit id:
    $ git log
    commit 83b90a07620ef578450c40a6d38bacc42de7ad2d
    Author: rohit01 <*@gmail.com>
    Date: Fri Feb 21 23:46:52 2014 +0530

Basically, predict the next git commit id and commit a file which contains that commit id.

like image 671
rohit01 Avatar asked Jan 12 '23 03:01

rohit01


1 Answers

That is cryptographically impossible.

The git commit ID is an SHA1 hash of the contents of the commit.
Any change you make in the commit will also affect the ID.

like image 195
SLaks Avatar answered Jan 19 '23 10:01

SLaks