31 January, 2020 - 2 min read
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
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.
%his the abbreviated hash of the commit
%dare any decorations on that commit (e.g. branch heads or tags)
%adis the author date
%sis the comment
%anis the author name
--graphinforms git to display the commit tree in an ASCII graph layout
--date=shortkeeps the date format nice and short
Both gitx (for Macs) and gitk (any platform) are useful in exploring log history.
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