Rambling Labs Blog Ramblings on software development

  • Showing git and mercurial repository information in PowerShell

    A while ago, I started getting a little annoyed when pushing my changes. It wasn't until *then *that I realized that I forgot to add a yet untracked file to the repository or that I was in the wrong branch.

    I made a quick Google search and found that I wasn't the only one with this problem, and that there are some pretty cool solutions out there.

    Since I'm currently developing in Windows, I found posh-git and posh-hg to be the more adequate ones.

    It's really easy. Just download them from here and here (or just go to links above and look for Downloads).

    Both posh-git and posh-hg provide a quick inline summary with the current branch name and the number of untracked files, added files, removed files, modified files, etc.

    ** **First of all, make sure you run "Set-ExecutionPolicy" followed by "Unrestricted" in the PowerShell console . This is because PowerShell doesn't run scripts by default (you could read further about it here).

    Also make sure that git and hg are in the PATH.

    To enable posh-git, just open a PowerShell console and run the "*install.ps1*" file downloaded with the posh-git package. You should now find some files in the "$HOME$\Documents\WindowsPowershell" folder ($HOME$ is usually the C:\Users\YourUserName).

    To enable posh-hg, copy the files to the just opened WindowsPowershell folder and open the profile.ps1 file to add the following line:

    . ./profile.example.ps1

    Then, restart PowerShell, go to a git or hg repository in your local machine with it, and you will get something like this:


    Isn't that cool?

  • blog comments powered by Disqus