git
git log --format="%aI%h"sortable list of dates and hashes
%aI = ISO date, %h = commit hash
git log -n 100 --pretty=format:"%h%x09%an%x09%ad%x09%s" --date=shortlist 100 most recent commits, one per line, with YYYY-MM-DD dates
%h = commit hash, %x09 = space, %an = author name, %ad = commit date, %s = commit message
git checkout master
git log ..dev --pretty=format:"%h%x09%ad%x09%s" --date=shortlist commits that a merge (a PR) from dev into master would add to master
%h = commit hash, %x09 = space, %ad = commit date, %s = commit message, --date=short = yy-MM-dd
git show --pretty="" --name-only abc123
git diff-tree --no-commit-id --name-only -r abc123list files changed in a commit. in the first command, the commit hash is optional and defaults to the last commit.
git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'show parent branch
git rebase -i --root branchnamerewrite whole branch history
git rebase -i HEAD~2rewrite history for last 2 commits
git branch -vvshow last commit & tracked remote
git reset --hard remoteName/branchNamereset hard to match remote
git show --name-onlyshow files in last commit
git log -- path/to/file.jsshow commits that changed file
git show a1b2c3 path/to/file.jsshow how a file changed in a commit
git config --global core.autocrlf inputconvert to LF on check in (Mac / Linux)
gitgit config --global core.autocrlf trueconvert to CRLF on check out (Windows)
GIT_COMMITTER_DATE="$(date)" git commit --amend --no-edit --date "$(date)"change date of last commit to current date
GIT_COMMITTER_DATE="Mon 20 Aug 2018 20:19:19 BST" git commit --amend --no-edit --date "Mon 20 Aug 2018 20:19:19 BST"change date of last commit to Mon 20 Aug 2018 20:19:19 BST
git show branchName:path/to/file.txt > original.txtgrab file.txt from branchName and save it as original.txt on the current branch