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
202
votes
3 answers

Remove refs/original/heads/master from git repo after filter-branch --tree-filter?

I had the same question as asked here: New git repository in root directory to subsume an exist repository in a sub-directory I followed this answer here: New git repository in root directory to subsume an exist repository in a sub-directory Now,…
goofeedude
  • 2,123
  • 2
  • 13
  • 4
17
votes
1 answer

How to replicate git-checkout using only plumbing commands?

I would like to avoid calling porcelain commands from my scripts, but is there a way to get some of the behavior of git checkout using only plumbing commands like checkout-index? I'm particularly interested in the effect on the working…
Jack O'Connor
  • 10,068
  • 4
  • 48
  • 53
10
votes
5 answers

Get a list of changed files and their status for a specific Git commit

I use the following Git command git diff-tree --no-commit-id --name-only -r to get a list of changed files. Unfortunately, the list doesn't specify the type of change for each file: added, modified or deleted ... etc How may I display a list…
Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
8
votes
2 answers

Git clone bare repo without blobs

On my git repository, I use an algorithm to assign every commit one or more unique version numbers, based on branch names and tags. I want to use this mechanism with another large repository, that I would like to clone without transferring any…
phi1010
  • 678
  • 6
  • 13
7
votes
1 answer

Are "dangling" and "loose" objects the same?

Git's fsck doc talks about "dangling" objects, while the gc doc talks only about "loose objects". There's a strict split. But while skimming a few related SO posts, the terms seem to be used interchangeably. In the Git Book v2 and Git's source code…
Katrin Leinweber
  • 1,316
  • 13
  • 33
6
votes
2 answers

git scripting: How to list all git branches containing a commit

I can list all branches containing a certain commit using git branch --list --contains just fine. But as explained in the related question on how to list all branches, this is a porcelain command that should not be used in scripts. The latter…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
5
votes
2 answers

How can I recover HEAD^'S tree?

tl;dr: is it possible to recover HEAD^'s tree if it is deleted and not pushed beforehand and if everything else is intact? I accidentally deleted part of my .git. I'm not entirely sure what's missing. Upon discovering that git push didn't work, I…
strugee
  • 2,752
  • 4
  • 19
  • 30
4
votes
2 answers

git plumbing command to get submodule remote

I am working with git plumbing and mirrored (and thus bare) repos, in a readonly filesystem. I can see the existence of submodules with git ls-tree. I can infer their name/path and the SHA1, but I can't find a way to get the submodule remote. The…
Josh Bleecher Snyder
  • 8,262
  • 3
  • 35
  • 37
4
votes
1 answer

Git save the all version of file added by using index update-index command?

I try to understand the plumbings command of git and how it's low-level actions build the high-level actions like add and commit. I know, that each time when I used the: git update-index file.txt i create the blob from this file and create the…
fingolfin
  • 77
  • 5
4
votes
1 answer

What plumbing command provides the same functionality as git log --follow?

In an effort to improve stability, I'm currently refactoring all my Git-related shell scripts so that they use only plumbing (rather than porcelain) commands. In particular, I'm trying to replace calls to git log (porcelain) by calls to git rev-list…
jub0bs
  • 60,866
  • 25
  • 183
  • 186
3
votes
1 answer

How to compare Github API hash with a local file hash?

I'm trying to compare the hash of local files with the hash from the GitHub API; I have created test.txt and uploaded it to my repo, when I call compute_sha1_hash on test.txt: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed The GitHub API response: …
Jabu
  • 51
  • 4
3
votes
3 answers

How do I find the date of a git commit using only plumbing commands?

There is already a question asking how to find the date of a commit in Git. However, all the answers to that question make use of the git show or git log commands, which are both porcelain commands; the standard wisdom on porcelain commands seems to…
Pont
  • 333
  • 3
  • 12
3
votes
1 answer

Git plumbing commands to detect submodule update and get the hashes in staging area or working directory

In porcelain mode, git diff advertises submodule changes: $ cd /opt/staging # This is the main Git repository $ cd software/zemke-rhyne # This is a submodule $ git pull $ git diff …
Dereckson
  • 1,340
  • 17
  • 30
3
votes
1 answer

Plumbing equivalent for `git checkout -- .`

I'm looking for a scripting-suitable plumbing command (or commands) that are equivalent to the high-level porcelain command git checkout -- . My initial thought would be to use git checkout-index --all --force, however this does not fully restore…
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
3
votes
1 answer

Git: get blob path in .git directory

I want to access some blobs at some point in repo history. Currently, I do that with git show $REV:$PATH. But files are quite large and I don't want them to be read and piped in script. I want to get their path and then read as plain files. May I…
George Sovetov
  • 4,942
  • 5
  • 36
  • 57
1
2 3 4