Last Updated: March 07, 2016
·
740
· robcthegeek

Git Alias for Quickly Adding .gitignore Files from GitHub

I'm not sure about you - but I am really tired of creating a new project in Visual Studio, and then setting up the .gitignore file to do it's thing.

So, I decided to make a quick little alias to sort it out for me.

GitHub have done a great thing and open-sourced their default ignore files - which is an excellent baseline for a new project.

Since I'm in the shell (having just created a new repository) - it makes sense to quickly get my ignores file while I am there!

$ git ignores

How did I do this?

I simply added this to my Git config:

[alias]
  ignores = !(curl -o .gitignore https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore)

Now, I can simply:

  • Create my new project/solution
  • git init
  • git ignores

... and I'm all set!

Be sure to check out the other files they have!

1 Response
Add your response

One thing to add that occurred to me this morning - you can do this with lots of files on GitHub, including files in secret gists. (they're 'secret' not 'private' - if you have the link you can still access them without logging in)

So, if you want to keep some files private, you can use the same solution above, but use the "raw" URL for a file in a secret gist.

over 1 year ago ·