Github logging
31 January, 2020 - 2 min read
Github immersion
I decided to spend the day learning github more in depth. One of my favourite resources is GithubImmersion. It can get intimidating to practice your work with a language you never really use (ruby), but I am getting less scared of trying new things and I just created the file to play around with.
One of the most interesting things that I have yet to add to my workflow, is git log
Getting a listing of what changes have been made is the function of the git log command.
There are a lot of options for selecting which entries are displayed in the log.
$ git log --pretty=oneline --max-count=2
$ git log --pretty=oneline --since='5 minutes ago'
$ git log --pretty=oneline --until='5 minutes ago'
$ git log --pretty=oneline --author=<your name>
$ git log --pretty=oneline --all
Here is a great log format that you can use for your own logs:
$ git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
It should output something like this:
6118034 2020-01-31 | added comment (HEAD -> master) [lalawuhan]
525466d 2020-01-31 | added a default value [lalawuhan]
b4cf229 2020-01-31 | Using Argv # [lalawuhan]
136ac2f 2020-01-31 | first [lalawuhan]
This is what it consists of:
--pretty="..."
defines the format of the output.%h
is the abbreviated hash of the commit%d
are any decorations on that commit (e.g. branch heads or tags)%ad
is the author date%s
is the comment%an
is the author name--graph
informs git to display the commit tree in an ASCII graph layout--date=short
keeps the date format nice and short
Other Tools
Both gitx (for Macs) and gitk (any platform) are useful in exploring log history.
Common Shortcuts
git status
, git add
, git commit
, and git checkout
are such common commands that it is useful to have abbreviations for them.
Add the following to the .gitconfig file in your $HOME directory.
.gitconfig
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
type = cat-file -t
dump = cat-file -p