Skip to main content
Kill -9 Club
Sign in

git

GitPackage: git

The version control tool, used here for configuration files as much as for code: who changed what, when, and how to go back. git status and git log are the two commands to know before any other.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

git -a
Automatically stages every modified *tracked* file before committing. It does not pick up untracked files, and above all it removes the decision step the index exists to provide.
git -m
Supplies the message on the command line instead of opening an editor. Fine for one sentence; beyond that the editor allows a message body, which -m makes awkward to write.
git --staged
Compares the index against the last commit, rather than the working tree against the index: the review of what the next commit will contain.
git --oneline
Reduces each commit to one line: short hash and message. The readable form when you are looking for what changed rather than reading one commit.
git --since
Shows only commits after that date. Accepts an absolute date as readily as a relative phrase ("3 days ago").
git --cached
Removes the file from the index without deleting it from disk: it stops being tracked and stays usable locally. Without this option, git rm deletes your copy too.
git --stat
Summarises the commit per file and per number of lines touched, instead of printing the full diff. The right view for judging a commit's scope before reading it.
git --abort
Cancels the merge in progress and returns the repository to its state before the command. Nothing already committed is lost.
git --branch
On git clone, checks out the state that name refers to — branch or tag — instead of the repository's default branch.
git -c
On git switch, creates the branch and moves onto it in one step, starting from the commit you are on.
git -v
On git remote, prints each remote's full address instead of just its name — that is, where commands actually fetch from and publish to.
git --source
On git restore, says which commit to take the file's content from. Without it the content comes from the index — or from HEAD when --staged is given. The restored file lands in the working tree as an unstaged modification, which git diff lets you read before committing it.
git --hard
On git reset, moves the branch *and* overwrites the working tree so it matches the commit named. Uncommitted changes are lost with no copy kept: the reflog records commits, not edits.
git --depth
Fetches only the last N commits. --depth 1 is enough to deploy and avoids copying the whole history onto the server.
git --porcelain
Stable output, meant to be read by a script rather than a person.
git --short
The short form of the output.

Lessons that teach it

git — command reference | Kill -9 Club