Questions tagged [git-plumbing]

"Plumbing" commands are a set of low-level Git commands that are ideal for scripting purposes.

Git commands are generally divided into two groups:

  • "Porcelain" commands
  • "Plumbing" commands

While porcelain commands are high-level interfaces for end-users (i.e. human beings), the low-level plumbing commands are designed to be used in automated scripts. The plumbing commands are ideal for this purpose, because unlike the UI-focused porcelain commands, the plumbing commands are meant to be backwards-compatible (to avoid breaking existing scripts), while the higher-level porcelain commands have less strict API contracts that prohibit breaking-changes.

Read more in the Git manual.

54 questions
3
votes
4 answers

Remove a commit's parent, thereby making it the initial commit

Note: I know this is rewriting history, will change all the hashes, and mess everyone else up. I want to take a commit, and remove its parent. Specifically, the commit should now look like an initial commit. That means its diff will change; it will…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
3
votes
1 answer

Expand git's autocomplete feature to plumbing commands

As a follow up to this question, I asked myself if it would be possible to tell git to provide it's autocomplete feature (branches etc.) for further commands, in particular plumbing commands like update-ref. Although update-ref provides more…
Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
3
votes
2 answers

Get all versions of a file from a single branch

Given a single branch in a git repository, how do I grab all versions of a file? The final desired output is one new output file per version (although printing all of the versions to STDOUT is fine as well, as long as it's easy to determine the…
Matt Fenwick
  • 48,199
  • 22
  • 128
  • 192
2
votes
2 answers

Why doesn't `git update-ref -d` delete empty parent directories?

There are various types of refs in git, some of the most common of which are branches (stored in .git/refs/heads), remote-tracking branches (.git/refs/remotes), and tags (.git/refs/tags). But it's also possible to create and use arbitrary…
kini
  • 1,781
  • 13
  • 23
2
votes
1 answer

How does `git rebase` work under the hood?

I recently started working with git trees and temporary index files to construct commits without modifying my working directory, for the purpose of automating some tasks. The ultimate goal is to effectively rebase some branch (e.g. feature/x_y_z on…
Nick Giampietro
  • 178
  • 1
  • 8
2
votes
2 answers

using git read-tree without a work tree

I am trying to create a commit history using git plumbing commands with a bare repo. I can create commits with a single unnamed tree object containing blobs, but I cannot figure out how to get this unnamed tree object to contain other tree…
prw56
  • 326
  • 2
  • 12
1
vote
3 answers

How to adjust parents of a Git commit permanently in history

I know how to solve this using traditional tools at hand, but I want to understand the possibilities and see whether things can be done more effectively. In this example - I want to add B as a second parent to C. main ∙∙∙A---C---D …
Qwerty
  • 29,062
  • 22
  • 108
  • 136
1
vote
0 answers

How to index to a particular commit without touching HEAD or any other ref?

Basically, I'm looking for the opposite of git reset --soft - ideally a plumbing command. I need to modify a particular index file (set via GIT_INDEX_FILE) to point to a specific commit, without altering any ref like HEAD (or anything else). Is…
user541686
  • 205,094
  • 128
  • 528
  • 886
1
vote
1 answer

Plumbing command to get the result of git-bisect with --no-checkout

I'm writing a script which automatically finds a specific commit. I've reached the part when I'm calling git bisect start --no-checkout and git bisect run ./my_check_commit_script.sh. It finds and displays the correct commit. However, I don't know…
Piotr Siupa
  • 3,929
  • 2
  • 29
  • 65
1
vote
2 answers

How does git cat-file -t determine the type of object?
The following link explains how Git computes object IDs (ruby code snippet). The object type (blob, tree, commit) is encoded in the header which is concatenated with the content and the SHA1 is computed on the concatenated…
katboo
  • 55
  • 7
1
vote
1 answer

Controlling the order files appear in Git

This is a very minor accessibility issue but I wonder if anyone has addressed it: Whenever I do git status the files appear in alphabetical order (as they should): ❯ git status On branch feature Untracked files: (use "git add ..." to include…
segfault
  • 339
  • 2
  • 8
1
vote
1 answer

GIT: Get all git object hashes of blobs added to the repository by a commit

Is it possible to get a list of all git object hashes of blobs which have been added to the repository by a given commit hash using the git command line tools? I already tried archiving this with the git plumbing tool git-diff-tree. Maybe it's the…
Daniel K.
  • 5,747
  • 3
  • 19
  • 22
1
vote
1 answer

Revert previously staged changes (or: undo changes to .git/index)

When trying to understand the ways to undo various git operations I came up with a scenario where I'm not sure how to deal with it. Disclaimer: I did not have this situation when actually working with git 'in production' but I'd still think it's not…
mvo
  • 1,138
  • 10
  • 18
1
vote
2 answers

Cannot create commit if the filename argument given to hash-object differs from the original filename

I'm toying with the git plumbing commands to get a better understanding of its inner mechanisms. I'm trying to reproduce a commit without using the git commit command. Let's create a blob: $ git init $ echo "I'm an apple" > apple.txt $ git…
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
1
vote
1 answer

Which plumbing commands achieve the same as git add?

I'd like to understand git-plumbing better by learning what actually happens when entering git add $DIRECTORY and git add $FILE How does it work? A rough idea can be gained by reading the progit's git internals section. If $DIRECTORY is a…
Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221