Git Toolbox

// Git Toolbox

.git inspector

The .git folder is your repository's brain. Here is what each part is for, what you can touch, and what it tells about your repo.

Contents of .git

  • HEAD

    Where you are: usually “ref: refs/heads/main”. A raw commit hash means detached HEAD.

    DestructiveDon't touch

    Look inside

    Safe
    $ cat .git/HEAD
  • config

    This repository's settings: remotes, branch tracking, local options. Edit it with git config rather than by hand.

    CautionCarefully

    Look inside

    Safe
    $ git config --local --list
  • description

    Only used by GitWeb. You can ignore it.

    SafeYou can touch it
  • index

    The staging area: the exact snapshot of your next commit (binary file).

    DestructiveDon't touch

    Look inside

    Safe
    $ git ls-files --stage
  • objects/

    The database: every version of every file (blobs), folder (trees), commit and annotated tag, compressed and named by their hash.

    DestructiveDon't touch

    Look inside

    Safe
    $ git count-objects -vH
    • pack/

      Objects packed together (.pack + .idx), with deltas between versions. Created by clone, fetch and git gc.

      DestructiveDon't touch

      Look inside

      Safe
      $ git verify-pack -v .git/objects/pack/*.idx | sort -k3 -n | tail -5
    • info/

      Extra information for the object store (alternates, packs list).

      SafeYou can touch it
    • a1//

      Loose objects: 2 first characters of the hash as folder, the other 38 as file name.

      DestructiveDon't touch

      Look inside

      Safe
      $ git cat-file -p <hash>
  • refs/

    Branches, tags and remote branches: small text files that contain a commit hash.

    CautionCarefully

    Look inside

    Safe
    $ git show-ref
    • heads/

      Your local branches. refs/heads/main contains the hash of main's last commit.

      CautionCarefully

      Look inside

      Safe
      $ git branch -v
    • tags/

      Your tags (v1.0.0…).

      CautionCarefully

      Look inside

      Safe
      $ git tag -n
    • remotes/

      The last known state of remote branches (origin/main…), updated by fetch.

      SafeYou can touch it

      Look inside

      Safe
      $ git branch -r
    • stash

      Your stashes.

      CautionCarefully

      Look inside

      Safe
      $ git stash list
  • packed-refs

    Many refs in one file, for speed. A branch can be here instead of refs/heads/.

    CautionCarefully

    Look inside

    Safe
    $ cat .git/packed-refs
  • logs/

    The reflog: every position HEAD and each branch had. This is what saves you after a bad reset.

    CautionCarefully

    Look inside

    Safe
    $ git reflog
    Learn more →
  • hooks/

    Scripts run by Git at key moments (pre-commit, pre-push…). Files ending in .sample are inactive examples.

    SafeYou can touch it
    Learn more →
  • info/

    info/exclude: a personal .gitignore that is never committed.

    SafeYou can touch it

    Look inside

    Safe
    $ cat .git/info/exclude
  • COMMIT_EDITMSG

    The message of your last commit, as typed in the editor.

    SafeYou can touch it
  • FETCH_HEADtemporary

    What the last fetch brought back.

    SafeYou can touch it

    Look inside

    Safe
    $ cat .git/FETCH_HEAD
  • ORIG_HEADtemporary

    Where HEAD was before the last dangerous operation (merge, rebase, reset).

    SafeYou can touch it

    Look inside

    Safe
    $ git log -1 ORIG_HEAD
  • MERGE_HEADtemporary

    The commit being merged.

    DestructiveDon't touch
    Learn more →
  • MERGE_MSGtemporary

    The prepared message of the merge commit.

    SafeYou can touch it
  • rebase-merge/temporary

    State of an interactive or merge-based rebase.

    DestructiveDon't touch
    Learn more →
  • rebase-apply/temporary

    State of a git am or an old-style rebase.

    DestructiveDon't touch
  • CHERRY_PICK_HEADtemporary

    The commit being cherry-picked.

    DestructiveDon't touch
  • REVERT_HEADtemporary

    The commit being reverted.

    DestructiveDon't touch
  • BISECT_LOGtemporary

    Steps of a git bisect.

    SafeYou can touch it
  • sequencer/temporary

    State of a cherry-pick or revert of several commits.

    DestructiveDon't touch
  • index.locktemporary

    Lock taken by a running Git command.

    CautionCarefully
    Learn more →
  • shallowtemporary

    Commits where the history stops (clone --depth).

    CautionCarefully
  • modules/

    The repositories of your submodules.

    CautionCarefully

    Look inside

    Safe
    $ git submodule status
  • worktrees/

    Extra working folders created with git worktree add.

    CautionCarefully

    Look inside

    Safe
    $ git worktree list
  • lfs/

    Git LFS: local copies of large files.

    CautionCarefully

    Look inside

    Safe
    $ git lfs ls-files
  • AUTO_MERGEtemporary

    Recent Git (2.42+): the tree Git merged automatically during the last merge, conflicts included. Handy to see what you changed while resolving.

    SafeYou can touch it

    Look inside

    Safe
    $ git diff AUTO_MERGE
  • gc.logtemporary

    Errors of the last automatic git gc.

    SafeYou can touch it

The 4 kinds of objects

blob
the content of a file (not its name)
tree
a folder: names → blobs and other trees
commit
a tree + parent(s) + author + message
tag
an annotated tag: a name and a message on a commit

See any object: git cat-file -p 1a2b3c4

What's in yours?

Paste the listing of your .git folder: the inspector tells you what is going on (merge in progress, lock left behind…).

Safe
$ ls -la .git
Safe
$ Get-ChildItem -Force .git
Everything stays in your browser.