# gitignore.io

Gitignore.io is a web service designed to help you create .gitignore files for your Git repositories.

### Video tutorial

{% embed url="<https://vimeo.com/204803019>" %}
gitignore.io video tutorial
{% endembed %}

### Customers

![These companies use gitignore.io](/files/-LYPG4Map-XBs55VLMcs)


# Command Line

To run gitignore.io from your command line you need an active internet connection and an environment function. You need to add a function to your environment that lets you access the gitignore.io API.

### Git

#### Bash <a href="#git-bash" id="git-bash"></a>

```bash
git config --global alias.ignore \
'!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}; gi'
```

### Linux

#### Bash <a href="#linux-bash" id="linux-bash"></a>

```bash
echo "function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> \
~/.bashrc && source ~/.bashrc
```

#### Zsh <a href="#linux-zsh" id="linux-zsh"></a>

```bash
echo "function gi() { curl -sLw \"\\\n\" https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> \
~/.zshrc && source ~/.zshrc
```

#### Fish <a href="#linux-fish" id="linux-fish"></a>

```bash
printf "function gi\n\tcurl -sL https://www.toptal.com/developers/gitignore/api/\$argv\nend\n" > \
~/.config/fish/functions/gi.fish
```

### macOS

#### Bash <a href="#macos-bash" id="macos-bash"></a>

```bash
echo "function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> \
~/.bash_profile && source ~/.bash_profile
```

#### Zsh <a href="#masos-zsh" id="masos-zsh"></a>

```bash
echo "function gi() { curl -sLw \"\\\n\" https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> \
~/.zshrc && source ~/.zshrc
```

#### Fish <a href="#macos-fish" id="macos-fish"></a>

```bash
printf "function gi\n\tcurl -sL https://www.toptal.com/developers/gitignore/api/\$argv\nend\n" > \
~/.config/fish/functions/gi.fish
```

### Windows

Paste the following scripts inside your PowerShell profile (run `$profile` inside PowerShell to get the profile's location path).

#### PowerShell v3 Script

```bash
#For PowerShell v3
Function gig {
  param(
    [Parameter(Mandatory=$true)]
    [string[]]$list
  )
  $params = ($list | ForEach-Object { [uri]::EscapeDataString($_) }) -join ","
  Invoke-WebRequest -Uri "https://www.toptal.com/developers/gitignore/api/$params" | select -ExpandProperty content | Out-File -FilePath $(Join-Path -path $pwd -ChildPath ".gitignore") -Encoding ascii
}
```

#### PowerShell v2 Script <a href="#windows-powershell-v2" id="windows-powershell-v2"></a>

```bash
#For PowerShell v2
Function gig {
  param(
    [Parameter(Mandatory=$true)]
    [string[]]$list
  )
  $params = ($list | ForEach-Object { [uri]::EscapeDataString($_) }) -join ","
  $wc = New-Object System.Net.WebClient
  $wc.Headers["User-Agent"] = "PowerShell/" + $PSVersionTable["PSVersion"].ToString()
  $wc.DownloadFile("https://www.toptal.com/developers/gitignore/api/$params", "$PWD\.gitignore")
}
```

Create a Command Line Prompt Script If you have installed [msysgit](http://msysgit.github.io/)), create `gi.cmd` with content below. And copy it to `C:\Program Files\Git\cmd\gi.cmd`, assuming `msysgit` was installed to `c:\Program Files\Git`. Make sure that `C:\Program Files\Git\cmd` is added to the environment variable `path`.

```bash
@rem Do not use "echo off" to not affect any child calls.
@setlocal

@rem Get the abolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@for /F "delims=" %%I in ("%~dp0..") do @set git_mingw_root=%%~fI\mingw
@if not exist "%git_mingw_root%" @set git_mingw_root=%git_install_root%\mingw64
@set PATH=%git_install_root%\bin;%git_mingw_root%\bin;%PATH%

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@curl.exe -L -s https://www.toptal.com/developers/gitignore/api/%*
```


# Editor Extensions

Tools or extensions maintained by third-party developers different editors.

### [Neovim](https://github.com/fszymanski/fzf-gitignore) — [Filip Szymański](https://github.com/fszymanski)

Install Neovim python client.

```bash
pip3 install --upgrade neovim
```

Use your favorite Neovim plugin manager to install `fzf-gitignore`.

```
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'}
Plug 'fszymanski/fzf-gitignore', {'do': ':UpdateRemotePlugins'}
```

### [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=rubbersheep.gi) — [Hasit Mistry](https://github.com/hasit/)

Press `Cmd+P` for MacOS and `Ctrl+P` for Linux/Windows to launch VS Code Quick Open, paste the following command, and press enter.

```
ext install gi
```

### [GNU Emacs](https://github.com/jupl/helm-gitignore) — [Juan Placencia](https://github.com/jupl)

This package is available on [MELPA](http://melpa.org/) under the name `helm-gitignore`. Please note that gitignore.io’s APIs are available through HTTPS, meaning if you experience issues attempting to connect to the network odds are you may need something like [GnuTLS](http://gnutls.org/).

###


# Client Applications

Clients maintained by third-party developers

### [Go](https://github.com/Gnouc/gogi) — [Cuong Manh Le](https://github.com/Gnouc)

```bash
go get -u github.com/Gnouc/gogi
```

### [Node](https://github.com/TejasQ/add-gitignore) — [Tejas Kumar](https://github.com/TejasQ)

You'll want to make sure you have [NodeJS](https://nodejs.org/en/) installed on your computer. Then, setup is as simple as:

```bash
npx add-gitignore
```

If you've got an older version of node that doesn't yet have [`npx`](https://www.npmjs.com/package/npx), here's a more traditional setup:

```bash
npm i -g add-gitignore
add-gitignore macOS Emacs node # or whatever you need
```

Alternatively, running just `add-gitignore` gives you a nice multi-select interface from which you can choose what to ignore, and using the `--help` flag helps you out.

### [Python](https://github.com/Antrikshy/ignr.py) — [Antriksh Yadav](https://github.com/Antrikshy)

```bash
pip install ignr
```

### [Rust](https://github.com/sondr3/git-ignore) — [Sondre Nilsen](https://github.com/sondr3)

```bash
cargo install git-ignore-generator
```


# Local Server

Install gitignore.io locally for testing, debugging, and submitting new application functionality.

### Requirements

* Vapor - [macOS](https://docs.vapor.codes/3.0/install/macos/) / [Ubuntu](https://docs.vapor.codes/3.0/install/ubuntu/)

### Local

```bash
$ git clone --recursive git@github.com:toptal/gitignore.io.git
$ cd gitignore.io/
$ vapor build
$ vapor run
```

### Docker

It’s also possible to run the app using [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/). It can be done by running the commands below.

```bash
$ git clone --recursive git@github.com:toptal/gitignore.io.git
$ cd gitignore.io/
$ docker-compose up -d
```


# Command Line

After the function is created, the `gi` command will give you command line access to the gitignore.io API. &#x20;

{% hint style="info" %}
Use `gig`if you are on Windows
{% endhint %}

### Preview

Show output on the command line.

{% tabs %}
{% tab title="Command" %}

```bash
gi linux,java
```

{% endtab %}

{% tab title="Response" %}

```
# Created by https://www.toptal.com/developers/gitignore/api/linux,java
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,java

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*


# End of https://www.toptal.com/developers/gitignore/api/linux,java
```

{% endtab %}
{% endtabs %}

### Global

Append Operating System and IDE settings to global .gitignore.

```bash
gi linux,eclipse >> ~/.gitignore_global
```

### Project

Appending Programming Language settings to your projects .gitignore.

```bash
gi java,python >> .gitignore
```

### List

{% tabs %}
{% tab title="Command" %}

```
gi list
```

{% endtab %}

{% tab title="Response" %}

```bash
1c,1c-bitrix,a-frame,actionscript,ada
adobe,advancedinstaller,agda,alteraquartusii,altium
android,androidstudio,angular,anjuta,ansible
apachecordova,apachehadoop,appbuilder,appceleratortitanium,appcode
appcode+all,appcode+iml,appengine,aptanastudio,arcanist
archive,archives,archlinuxpackages,aspnetcore,assembler
atmelstudio,ats,audio,automationstudio,autotools
backup,ballerina,basercms,basic,batch
bazaar,bazel,bitrix,bittorrent,blackbox
bluej,bookdown,bower,bricxcc,buck
c,c++,cake,cakephp,calabash
carthage,ceylon,cfwheels,chefcookbook,clean
clion,clion+all,clion+iml,clojure,cloud9
cmake,cocoapods,cocos2dx,cocoscreator,code
code-java,codeblocks,codecomposerstudio,codeigniter,codeio
codekit,coffeescript,commonlisp,composer,compressed
compressedarchive,compression,concrete5,coq,craftcms
crashlytics,crbasic,crossbar,crystal,csharp
cuda,cvs,d,dart,darteditor
data,database,datarecovery,dbeaver,delphi
diskimage,django,dm,docfx,dotfilessh
dotsettings,dreamweaver,dropbox,drupal,drupal7
drupal8,eagle,easybook,eclipse,eiffelstudio
elasticbeanstalk,elisp,elixir,elm,emacs
ember,ensime,episerver,erlang,espresso
executable,expressionengine,extjs,fancy,fastlane
finale,firebase,flashbuilder,flex,flexbuilder
floobits,flutter,font,fontforge,forcedotcom
forgegradle,fortran,freepascal,fsharp,fuelphp
fusetools,games,gcov,genero4gl,geth
ggts,gis,git,gitbook,go
godot,gpg,gradle,grails,greenfoot
grunt,gwt,haskell,hexo,homeassistant
hsp,hugo,hyperledgercomposer,iar,iar_ewarm
iarembeddedworkbench,idris,igorpro,images,infer
inforcrm,intellij,intellij+all,intellij+iml,ionic3
jabref,java,java-web,jboss,jboss-4-2-3-ga
jboss-6-x,jdeveloper,jekyll,jetbrains,jetbrains+all
jetbrains+iml,jigsaw,jmeter,joe,joomla
jspm,julia,jupyternotebook,justcode,kate
kdevelop4,keil,kentico,kicad,kirby2
kobalt,kohana,komodoedit,kotlin,labview
lamp,laravel,latex,lazarus,leiningen
lemonstand,less,liberosoc,librarian-chef,libreoffice
lilypond,linux,lithium,lua,lyx
m2e,macos,magento,magento2,magic-xpa
matlab,maven,mavensmate,mean,mercurial
mercury,metaprogrammingsystem,meteorjs,microsoftoffice,mikroc
moban,modelsim,modx,momentics,monodevelop
mplabx,mule,nanoc,nativescript,ncrunch
nesc,netbeans,nette,nikola,nim
ninja,node,notepadpp,nwjs,objective-c
ocaml,octobercms,opa,opencart,opencv
openfoam,openframeworks,oracleforms,osx,otto
packer,particle,pawn,perl,perl6
ph7cms,phalcon,phoenix,phpcodesniffer,phpstorm
phpstorm+all,phpstorm+iml,pimcore,pinegrow,platformio
playframework,plone,polymer,powershell,premake-gmake
prepros,prestashop,processing,progressabl,psoccreator
puppet-librarian,purebasic,purescript,pvs,pycharm
pycharm+all,pycharm+iml,pydev,python,qml
qooxdoo,qt,qtcreator,r,racket
rails,reactnative,red,redcar,redis
rhodesrhomobile,rider,root,ros,ruby
rubymine,rubymine+all,rubymine+iml,rust,salesforce
salesforcedx,sas,sass,sbt,scala
scheme,scons,scrivener,sdcc,seamgen
senchatouch,serverless,shopware,silverstripe,sketchup
slickedit,smalltalk,snapcraft,solidity,soliditytruffle
sonar,sonarqube,sourcepawn,splunk,spreadsheet
standardml,stata,stdlib,stella,stellar
stylus,sublimetext,sugarcrm,svn,swift
swiftpackagemanager,swiftpm,symfony,symphonycms,synology
synopsysvcs,tags,tarmainstallmate,terraform,test
testcomplete,testinfra,tex,text,textmate
textpattern,theos-tweak,tortoisegit,tower,turbogears2
typings,typo3,umbraco,unity,unrealengine
vaadin,vagrant,valgrind,vapor,venv
vertx,video,vim,virtualenv,virtuoso
visualstudio,visualstudiocode,vivado,vvvv,waf
wakanda,web,webmethods,webstorm,webstorm+all
webstorm+iml,werckercli,windows,wintersmith,wordpress
wyam,xamarinstudio,xcode,xcodeinjection,xilinxise
xilinxvivado,xill,xojo,xtext,y86
yeoman,yii,yii2,zendframework,zephir
zukencr8000
```

{% endtab %}
{% endtabs %}


# Advanced Command Line

Here are some advanced command line improvements for gitignore.io

### [**@git2samus**](https://github.com/git2samus)

this allows invocations as the previous but also permits passing arguments to curl like: gi --proxy somewhere:8080 -- linux python

```bash
function gi() (
    gi_args=()
    for arg; do
        if [[ $arg = -- ]]; then
            curl_args=("${gi_args[@]}")
            gi_args=()
        else
            gi_args+=("$arg")
        fi
    done
    IFS=,
    curl "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
)
```

### [**@git2samus**](https://github.com/git2samus)

Adds a check to see if curl or wget is installed.

```bash
if hash curl; then
    curl "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
elif hash wget; then
    wget -O- "${curl_args[@]}" https://www.toptal.com/developers/gitignore/api/"${gi_args[*]}"
else
    echo "please install curl or wget to run this command" >&2
    exit 1
fi
```

### [**@GeorgeErickson**](https://github.com/GeorgeErickson)

Bash one-liner

```bash
function gi { curl https://www.toptal.com/developers/gitignore/api/"$(IFS=, ; echo "$*")"; }
```

### [**@SantoshSrinivas79**](https://github.com/SantoshSrinivas79)

Create a file for the function using vim \~/.config/fish/functions/gi.fish and enter the below code

```
function gi
  curl -L -s https://www.toptal.com/developers/gitignore/api/$argv;
end
```

### [**oh-my-zsh**](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/gitignore/gitignore.plugin.zsh)

Provides completion for zsh

```bash
function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}

_gitignoreio_get_command_list() {
  curl -sL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n"
}

_gitignoreio () {
  compset -P '*,'
  compadd -S '' `_gitignoreio_get_command_list`
}

compdef _gitignoreio gi
```

### [**@z**ubin](https://github.com/zubin)

Provides completion for fish

```bash
complete -f -c git -n '__fish_git_using_command ignore' -a '(__fish_print_gitignore_list)'

function __fish_print_gitignore_list
if ! set -q __FISH_PRINT_GITIGNORE_LIST
   set -g __FISH_PRINT_GITIGNORE_LIST (curl -sL https://www.toptal.com/developers/gitignore/api/list)
end
echo $__FISH_PRINT_GITIGNORE_LIST | string split ","
end
```

### [**@Phoenix09**](https://github.com/Phoenix09)

Improved git alias `tee` to `.gitignore` and accept multiple parameters

```bash
git config --global alias.ignore \
'!gi() { IFS=","; curl -L -s "https://www.toptal.com/developers/gitignore/api/$*" | tee .gitignore;}; \
gi'

```


# API

Open JSON API for integrating with gitignore.io

## Get All Templates

<mark style="color:blue;">`GET`</mark> `https://www.toptal.com/developers/gitignore/api/list?format=:format:`

This endpoint allows you to get free cakes.

#### Query Parameters

| Name   | Type   | Description                                                 |
| ------ | ------ | ----------------------------------------------------------- |
| format | string | The format of the list response `lines` (default) or `json` |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
	"jboss4": {
		"key": "jboss4",
		"name": "JBoss4",
		"contents": "\n### JBoss4 ###\n# gitignore for JBoss v4 projects\n\n\/server\/all\/data\n\/server\/all\/log\n\/server\/all\/tmp\n\/server\/all\/work\n\/server\/default\/data\n\/server\/default\/log\n\/server\/default\/tmp\n\/server\/default\/work\n\/server\/minimal\/data\n\/server\/minimal\/log\n\/server\/minimal\/tmp\n\/server\/minimal\/work\n\n# Note:\n# there may be other directories that contain *.xml.failed or *.war.failed files\n\/server\/default\/deploy\/*.xml.failed\n\/server\/default\/deploy\/*.war.failed\n",
		"fileName": "JBoss4.gitignore"
	},
	"extjs": {
		"key": "extjs",
		"name": "ExtJs",
		"contents": "\n### ExtJs ###\n.architect\nbootstrap.css\nbootstrap.js\nbootstrap.json\nbootstrap.jsonp\nbuild\/\nclassic.json\nclassic.jsonp\next\/\nmodern.json\nmodern.jsonp\nresources\/sass\/.sass-cache\/\nresources\/.arch-internal-preview.css\n.arch-internal-preview.css\n",
		"fileName": "ExtJs.gitignore"
	}
	...
}
```

{% endtab %}
{% endtabs %}


# Logo

Logo assets for websites or projects which showcase gitignore.io or use the API

![Horizontal lockup](/files/-LYPUXx5_R-ynVk7EMWp)

{% file src="/files/-LYPUXx5\_R-ynVk7EMWp" %}
Download horizontal lockup - vector
{% endfile %}

![Square lockup](/files/-LYPUXx4M0rvJdq9Uvr3)

{% file src="/files/-LYPUXx4M0rvJdq9Uvr3" %}
Download square lockup - vector
{% endfile %}


