Ayush's Blog

Git Tips

1. Create Github gists from terminal

  brew install gist
  • gist --login to give OAuth access to the application so that it can create gists on your behalf. Otherwise it creates anonymous gists.
  • Now read the documentation via gist -h and use it according to what you want.

2. Checking git repositories on your browser locally

Every one has faced the issue of Github not showing the complete blob diff for a file because it is too large. It asks you to see the diff on your own machine, locally.

Github Diff too big file Github Diff too big

If you are my kind who doesn’t like seeing big diffs in terminal, then this solution is for you.

Git has a hidden feature to let you browse your repository on browser. This command starts a local server for your repository:

1
git instaweb

The issue is that there is not straight way of looking at blob diff between two specific commits.

Digging into the documentation I found that passing the correct parameters can help you see the diff.

1
2
let SHA1 = SHA of commit to check diff from
let SHA2 = SHA of commit to check diff to

Once we have SHA1 and SHA2 resolved, Just create the URL like:

1
2
3
4
5
6
http://127.0.0.1:1234/? # Endpoint on which git is running instaweb
p=.git;
a=blobdiff;
f=file-path-to-check-diff-of;
hb=SHA1;
hpb=SHA2

Just open this URL in your favourite browser and you would be able to see the diff of the file.