Show the state of the working tree and staging area relative to the HEAD.
I never ever use git status
, I just find it harder to read.
I haven't yet gotten around to making git status
behave like git status -s
.
I know there's a simple way to configure that globally...
Show the diff between the working tree and the staging area,
or between the staging area and the HEAD, respectively.
If a path is given, show the diff only for files matching it.
Add the given files and directories in the working directory to the staging area.
Use git add .
to add all changes to the staging area.
This also adds files which were previously untracked by git.
(As long as they haven't been .gitignore
d.)
I usually instead use the -a
option of git commit
to effectively skip the staging area,
but git add
is sometimes useful to prepare specific changes for the next commit,
and is also required to add new (as opposed to merely modified) files to the next commit.
I usually use the -a
option instead of git add
ing files individually.
I almost always use the -m
option to specify the commit message on the command line, since it's usually a one-liner in my case.
I always use single-quote escapes to make sure all characters are automatically escaped. For example:
git commit -am 'This is my commit message. It'\''s really cool!'
Note the use of '\''
to effectively escape the single quote within the single quote escape.
By the way, git commit -am "This is my commit message. It's really cool!"
wouldn't work as intended (at least with bash)
since !
is still interpreted as a special command even within double quotes.
And forget git commit -am "This is my commit message. It's really cool\!"
because it would yield a commit message of "This is my commit message. It's really cool\!".
Yeah, shell scripting is screwy like that. So now you see why I ALWAYS use single-quote escapes in this case...
I also sometimes use git commit --amend
, but only if I screwed up the commit message, else I just go with a manual git reset HEAD^
, etc.
By default, pushes the current branch (HEAD) to the origin.
Use the --tags
option to also push all local tags.
Sometimes, after pushing to one of my websites, I notice a mistake, and since I haven't yet pushed to github,
I, hum, "do a little dance" that I'll document elsewhere at some point, and at the end of it all I do git push -f live
.
Show past commits on the current branch. If paths are specified, show only the commits that affected those paths.