Skip to main content
Update for Python3, 6 years later it makes sense to default to Python3
Source Link
cincodenada
  • 3k
  • 28
  • 36
export GIT_AUTHOR_DATE="1970-01-01T00:00:00+0000"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_AUTHOR_NAME="Author Name" \
export GIT_COMMITTER_DATE="2000-01-01T00:00:00+0000" \
export GIT_COMMITTER_EMAIL="[email protected]" \
export GIT_COMMITTER_NAME="Committer Name" \

git init

# First commit.
echo
touch a
git add a
git commit -m 'First message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/45/3a2378ba0eb310df8741aa26d1c861ac4c512f | hd

# Second commit.
echo
touch b
git add b
git commit -m 'Second message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/74/8e6f7e22cac87acec8c26ee690b4ff0388cbf5 | hd
export GIT_AUTHOR_DATE="1970-01-01T00:00:00+0000"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_AUTHOR_NAME="Author Name" \
export GIT_COMMITTER_DATE="2000-01-01T00:00:00+0000" \
export GIT_COMMITTER_EMAIL="[email protected]" \
export GIT_COMMITTER_NAME="Committer Name" \

git init

# First commit.
echo
touch a
git add a
git commit -m 'First message'
python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" \
  <.git/objects/45/3a2378ba0eb310df8741aa26d1c861ac4c512f | hd

# Second commit.
echo
touch b
git add b
git commit -m 'Second message'
python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" \
  <.git/objects/74/8e6f7e22cac87acec8c26ee690b4ff0388cbf5 | hd
export GIT_AUTHOR_DATE="1970-01-01T00:00:00+0000"
export GIT_AUTHOR_EMAIL="[email protected]"
export GIT_AUTHOR_NAME="Author Name" \
export GIT_COMMITTER_DATE="2000-01-01T00:00:00+0000" \
export GIT_COMMITTER_EMAIL="[email protected]" \
export GIT_COMMITTER_NAME="Committer Name" \

git init

# First commit.
echo
touch a
git add a
git commit -m 'First message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/45/3a2378ba0eb310df8741aa26d1c861ac4c512f | hd

# Second commit.
echo
touch b
git add b
git commit -m 'Second message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/74/8e6f7e22cac87acec8c26ee690b4ff0388cbf5 | hd
added 70 characters in body
Source Link
  • Top level:

    commit {size}\0{content}
    

    where {size} is the number of bytes in {content}.

    This follows the same pattern for all object types.

  • {content}:

    tree {tree_sha}
    {parents}
    author {author_name} <{author_email}> {author_date_seconds} {author_date_timezone}
    committer {committer_name} <{committer_email}> {committer_date_seconds} {committer_date_timezone}
    
    {commit message}
    

    where:

    • {tree_sha}: SHA of the tree object this commit points to.

      This represents the top-level Git repo directory.

      That SHA comes from the format of the tree object: What is the internal format of a Git tree object?

    • {parents}: optional list of parent commit objects of form:

      parent {parent1_sha}
      parent {parent2_sha}
      ...
      

      The list can be empty if there are no parents, e.g. for the first commit in a repo.

      Two parents happen in regular merge commits.

      More than two parents are possible with git merge -Xoctopus, but this is not a common workflow. Here is an example: https://github.com/cirosantilli/test-octopus-100k

    • {author_name}: e.g.: Ciro Santilli. Cannot contain <, \n

    • {author_email}: e.g.: [email protected]. Cannot contain >, \n

    • {author_date_seconds}: seconds since 1970, e.g. 946684800 is the first second of year 2000

    • {author_date_timezone}: e.g.: +0000 is UTC

    • committer fields: analogous to author fields

    • {commit message}: arbitrary.

  • Top level:

    commit {size}\0{content}
    

    where {size} is the number of bytes in {content}.

    This follows the same pattern for all object types.

  • {content}:

    tree {tree_sha}
    {parents}
    author {author_name} <{author_email}> {author_date_seconds} {author_date_timezone}
    committer {committer_name} <{committer_email}> {committer_date_seconds} {committer_date_timezone}
    
    {commit message}
    

    where:

    • {tree_sha}: SHA of the tree object this commit points to.

      This represents the top-level Git repo directory.

      That SHA comes from the format of the tree object: What is the internal format of a Git tree object?

    • {parents}: optional list of parent commit objects of form:

      parent {parent1_sha}
      parent {parent2_sha}
      ...
      

      The list can be empty if there are no parents, e.g. for the first commit in a repo.

      Two parents happen in regular merge commits.

      More than two parents are possible with git merge -Xoctopus, but this is not a common workflow.

    • {author_name}: e.g.: Ciro Santilli. Cannot contain <, \n

    • {author_email}: e.g.: [email protected]. Cannot contain >, \n

    • {author_date_seconds}: seconds since 1970, e.g. 946684800 is the first second of year 2000

    • {author_date_timezone}: e.g.: +0000 is UTC

    • committer fields: analogous to author fields

    • {commit message}: arbitrary.

  • Top level:

    commit {size}\0{content}
    

    where {size} is the number of bytes in {content}.

    This follows the same pattern for all object types.

  • {content}:

    tree {tree_sha}
    {parents}
    author {author_name} <{author_email}> {author_date_seconds} {author_date_timezone}
    committer {committer_name} <{committer_email}> {committer_date_seconds} {committer_date_timezone}
    
    {commit message}
    

    where:

    • {tree_sha}: SHA of the tree object this commit points to.

      This represents the top-level Git repo directory.

      That SHA comes from the format of the tree object: What is the internal format of a Git tree object?

    • {parents}: optional list of parent commit objects of form:

      parent {parent1_sha}
      parent {parent2_sha}
      ...
      

      The list can be empty if there are no parents, e.g. for the first commit in a repo.

      Two parents happen in regular merge commits.

      More than two parents are possible with git merge -Xoctopus, but this is not a common workflow. Here is an example: https://github.com/cirosantilli/test-octopus-100k

    • {author_name}: e.g.: Ciro Santilli. Cannot contain <, \n

    • {author_email}: e.g.: [email protected]. Cannot contain >, \n

    • {author_date_seconds}: seconds since 1970, e.g. 946684800 is the first second of year 2000

    • {author_date_timezone}: e.g.: +0000 is UTC

    • committer fields: analogous to author fields

    • {commit message}: arbitrary.

added 196 characters in body
Source Link
Loading
added 192 characters in body
Source Link
Loading
sys.stdout
Source Link
Loading
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
Loading
added 4055 characters in body
Source Link
Loading
added 1 character in body
Source Link
Loading
Source Link
Loading