Friday Fun: Git Tip of the Day

This year I’ve really taken to learning Git and how to incorporate it into my daily work routine. If nothing else this has been a great reminder about what it is like to learn something totally new and foreign. I’ve learned quite a bit, but am far from considering myself a master.  Git is a big topic so I’m always looking for new ways to learn and use it.

I mentioned git the other day on Twitter and someone pointed me to the Git-Tips project on GitHub. The project is essentially a list of git tips stored in a JSON file. Very nice. Now, I don’t want to read the tips and hope I’ll remember them all so I came up with a plan to display a “Git Tip of the Day” every time I opened a PowerShell session, including the ISE. Here’s how I did it.

First, I’m going to assume you have the latest version of Git installed. Next, go to the Git Tips project on GitHub. From here you two choices. You can download the current project as a zip file. Extract the folder to a location of your choice. The downside to this approach is that when new tips are added, you would need to re-download and extract. I recommend you create a local clone.

On the GitHub page click the Clone or Download button.

cloning git tips

Cloning Git Tips

Copy the URL to the clipboard. Next, open a PowerShell or CMD prompt. Navigate to the top level folder where you want to create the clone. In my case, I changed to C:\Scripts. Run this command:

This will create a new directory called Tips which will be a Git clone. You can create the folder where ever you want. If you want to see all of the tips you can use a PowerShell expression like this:

Git Tips

Git Tips

But I want to display a randomly selected tip every time I start PowerShell. I wrote this simple script:

Then in my PowerShell profile for current user all hosts I added this line.

Now when I start PowerShell I am greeted with a tip.

git tip of the day

Git Tip of the Day

That’s it! The only thing you might want to do is periodically check the status of the cloned repository and pull new changes as needed. You can actually pull anytime you want.

managing the repository

Managing the repository

The great thing about Git is that your local repository is completely separate. If you decide you no longer need it, simply delete the folder. It will have no effect anywhere else.

I’m excited to continue learning about Git and my tip of the day script has already taught me a few new things. I hope you find it useful as well.