Skip to content

Instantly share code, notes, and snippets.

@ericwastaken
Last active October 28, 2021 23:58
Show Gist options
  • Save ericwastaken/e441a0764562771a8dd4d3964e75618a to your computer and use it in GitHub Desktop.
Save ericwastaken/e441a0764562771a8dd4d3964e75618a to your computer and use it in GitHub Desktop.
A Cheat Sheet with some interesting GIT commands

GIT Cheat Sheet

This is a sheet with some interesting GIT commands.

License

This content is shared under a Creative Commons Attribution-ShareAlike 4.0 International.

Git History

In some of the below, the command also filters for commits after a certain date by using the --after parameter.

One Line Git History using the predefined 'reference' format

$ git log --pretty=reference --after 2018-12-01

Produces:

7787acc (New variables added, 2019-12-17)
eda85ed (Added new fields, 2019-12-06)

Custom Git History One-Line in CSV format

Generates a single line "csv" style from commit history using just the title of the commmit comments (the first line of the commit statement)

$ git log --pretty='format:"%s","%ad","(%C(auto)%h)"' --after 2018-12-01

Produces:

"Merged in PT170761145-2PC-Setup (pull request #35)","Mon Jan 20 22:35:26 2020 +0000","(f6f0587)"
"Implemented local config read, set apiURL as a application variable, read it for all API calls","Mon Jan 20 11:59:05 2020 -0800","(9f8f13f)"

Custom Git History, Text Oriented

$ git log --after 2020-06-14 --pretty=format:'(%h) by %an: %s%b'

Produces:

(2f77024) by Erik: looping over test data working
(ba8f795) by Erik: added gitignore
(de931f1) by Erik: rules engine now returns template transformed messages

Custom Git History, With Dates

$ git log --pretty='format:* %C(auto)%h: (%as | %an) %s' --after 2020-11-19 > ~/Desktop/deploy-log.txt

Produces:

* cf743ee: (2021-07-07 | Jason Alderman) Fixed broken link, typos, references to 1Password vault.
* 085d485: (2021-07-07 | Jason Alderman) Change git clone commands to SSH to use key instead of deprecated password.
* e958ed5: (2020-11-20 | Daniel L Morris) Merge pull request #4 from valtech-sd/dan/IPB-162-application-logger

For more information on pretty formats see the Git - pretty-formats Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment