Is it possible to skip the staging area and (also) commit untracked, new files to git?
Using a single, built-in, command-line command? No.
Using two commands:
git add -A
git commit
Using a custom alias:
Add this to .gitconfig:
[alias]
commituntracked = "!git add -A; git commit"
Then you can do
git commituntracked
This might seem quite trivial for the gurus, but is a minor revelation to me (I admit) - at least I just used it for the first time now and it works (without custom aliases): Just use a semicolon ;
and it'll work as a one-liner:
git add --all; git commit -m "some informative commit message"
Yes. There are at least two major ways of doing that. First, you don't have to use "the" staging area, you can have as many staging areas as you like -- set GIT_INDEX_FILE=/path/to/private/index
and do as you please; second you can construct commits yourself, directly. It isn't even hard.
Git's repository core deals with blob, tree, and commit objects (also, not so relevant here, notes and annotated tags). The git command to dump objects is git cat-file -p
.
A blob is just a bag-o-bits. Add one to the repository with git hash-object -w
filename
, it'll print the ~true name~ of the blob in that file and add the blob to the repo. A tree ties an object to a filesystem name. Add one to the repository with git mktree
; to see what to feed it, print a tree with e.g. git cat-file -p HEAD^{tree}
. Add a commit to the repository with git commit-tree
, basically, you say git commit-tree -p
mom
-p
dad sometree
, set some environment variables, and feed it a commit message on stdin.
That's really all that's necessary; if you want to get further into slicing and dicing with trees and staging read-tree
and write-tree
can be very useful, if this is at all attractive to you the git core tutorial is a good overview.