Watch projects evolve with Git
Git is not only the best VCS that I know of.
It's also great for watching projects evolve, from first to last commit.
Such an ease of history traversal makes me think of Git as a time machine-kind of tool.
To use Git as a time machine define these aliases in your ~/.gitconfig
:
# print first commit hash
first=rev-list --max-parents=0 HEAD
# check out the first commit
cof=!git checkout $(git first)
# checkout child commit
k=!git checkout $(git log --oneline HEAD..master | tail -1 | cut -d' ' -f1)
# checkout parent commit
j=!git checkout HEAD^$(git show --pretty=raw HEAD | grep ^parent | wc -l)
Use these aliases and tree
to watch a project evolve:
$ gcof
Checking out files: 100% (383/383), done.
Previous HEAD position was 1041098 upate Post#show route
HEAD is now at 9d35b59 initial commit
$ gk | tree app -I 'views|assets'
app
├── channels
│ └── application_cable
│ └── connection.rb
...
$ gk | tree app -I 'views|assets'
app
├── channels
│ └── application_cable
│ ├── channel.rb
│ └── connection.rb
...
You can tailor the tree command to target specific directories.
Gource and gitk are some other nice GUI tools to explore a project's history.
To explore the diff history use whatchanged
:
# show the last N diffs (N defaults to -1 which prints the entire history)
w=!N=${1:--1} sh -c 'git whatchanged -p -n $N'
# like `w` but in reverse order
wr=!N=${1:--1} sh -c 'git whatchanged -p -n $N --reverse'
# like `w` but print only the file names
wn=!N=${1:--1} sh -c 'git whatchanged -n $N --name-only --pretty=oneline'