Does anyone know of a git plumbing (definitely not porcelain) means of determining whether:
I am looking to determine this programmatically, hence the desire to not solve this with porcelain and various sed-fu.
Update: as mentioned below by toupeira, you can use the --porcelain
option of git status (since commit 6f15787, September 2009, git 1.7.0).
I mentioned in my answer "What does the term porcelain mean in Git?" that:
Perhaps the meaning of
--porcelain
here is "produce output suitable for consumption by porcelain scripts"
However, that won't show the ahead/behind information: see "What to add to “git status --porcelain” to make it behave like “git status”?": for that, you would still need to use other commands: see "How to know if git repository has changes that have not been synchronized with server?"
Initial answer March 2009
In porcelain command, a:
$ git diff HEAD
gives you the changes since the last commit (what you would be committing if you run "git commit -a").
A possible equivalent in plumbing command would be:
$ git ls-files -m
for listing all modified (working directory or index) files
If you create your repository by cloning someone else's repository, the remote "master" branch is copied to a local branch named "origin". You get your own "master" branch which is not tied to the remote repository.
There is always a current head, known as HEAD. (This is actually a symbolic link, .git/HEAD, to a file like refs/heads/master.)
run "git status" and analyze the output:
# On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
More details in the SO question "Why is Git telling me “Your branch is ahead of ‘origin/master’ by 11 commits.” and how do I get it to stop?"
Possible equivalent in plumbing command:
* git-for-each-ref
for listing all commits, but requires analyzing the output as well...
Again, git ls-files could be used to produced the same result than a git status.
git ls-files --exclude-per-directory=.gitignore --exclude-from=.git/info/exclude \
--others \
--modified \
-t
git status
now has a --porcelain
argument for scripting purposes (as well as an alternative -z
for machine parsing), this is preferred to git ls-files
which doesn't show files added to the index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With