Skip to content

Instantly share code, notes, and snippets.

@schacon
Created August 18, 2011 04:51
Show Gist options
  • Select an option

  • Save schacon/1153310 to your computer and use it in GitHub Desktop.

Select an option

Save schacon/1153310 to your computer and use it in GitHub Desktop.
plumbing cheat sheet

the plumbing commands

  • rev-parse [something]

    • show the SHA of any weird git phrase
  • hash-object -w [file]

    • take any file or stdin and return a blob sha
  • ls-tree (-r) [sha]

    • show the entries of a git tree in the db
  • ls-files -s

    • show the entries of the index
  • read-tree

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

    • take an existing blob or a file from the work tree and update the index entry
  • 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
  • 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)
@ddcz12
Copy link

ddcz12 commented Sep 15, 2018

What about cat-file -p and cat-file -t?

@Adii-Baadshah
Copy link

With these Git commands, developers can work with various Git plumbing operations, essential for managing repositories. Use them as a foundation for any Git operations, just like finding a reliable service; think of Git as the database and these commands as tools to find cheap plumber here for your repository's plumbing needs.

@jaindeen4
Copy link

This is actually a really interesting breakdown of the Git plumbing commands, and I’ve been trying to understand them better myself. I’m familiar with the common porcelain commands like git commit, git add, and git checkout, but when I started looking into the plumbing layer it quickly became confusing. Commands like rev-parse, hash-object, write-tree, and commit-tree seem to show how Git really works internally, but it’s not always obvious how they fit together in a real workflow. Seeing them listed like this helps a bit, but I’m still trying to understand when someone would actually use these directly instead of relying on the higher-level commands.

I also have the same question about how these commands connect step-by-step inside Git’s internal process. For example, how the flow goes from hashing a file, updating the index, writing the tree, and finally creating a commit and updating a reference. I’ve read that this sequence essentially recreates what git add and git commit do behind the scenes, but I’d really like to see a simple practical example of using these plumbing commands together. If anyone has a clear explanation or demo of the full chain from file → blob → tree → commit → ref, I’d really appreciate it because I’m trying to wrap my head around it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment