Skip to content

Instantly share code, notes, and snippets.

@beli-sk
Forked from schacon/plumbing.md
Last active February 16, 2024 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save beli-sk/8d15c7332622ef0c632a900bbec78468 to your computer and use it in GitHub Desktop.
Save beli-sk/8d15c7332622ef0c632a900bbec78468 to your computer and use it in GitHub Desktop.
git plumbing cheat sheet

the plumbing commands

refs

  • update-ref

    • update a branch (or other reference) to point to a specific commit sha
  • symbolic-ref

    • update a reference (usually HEAD) to point to another reference (like a branch)
  • rev-parse [something]

    • show the SHA of any weird git phrase

objects

  • hash-object -w [file]

    • take any file or stdin and return a blob sha, optionally write to db
  • cat-file

    • provide content or type and size information for repository objects
  • ls-tree (-r) [sha]

    • show the entries of a git tree in the db
  • read-tree

    • make the index look like a git tree in the db
  • write-tree

    • record the current state of the index into a git tree in the db and return the sha
  • commit-tree

    • create a commit object from a git tree in the db

index

  • ls-files -s

    • show the entries of the index
  • update-index

    • take an existing blob or a file from the work tree and update the index entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment