On Windows, use Git Bash (in Windows Explorer, right click and Git Bash Here) to run git commands.
If you try to create a
.gitignore file using Windows Explorer, Windows will get angry with you. Instead, open Git Bash in your project directory and enter
If you are really, really want to use Windows Explorer, there are reports you can specify
.gitignore. as the file name (with a trailing period) to fool Windows into accepting it. But who knows for how long. Whichever way you do it, be sure the file you create is called
.gitignore (and not e.g.,
.gitignore.txt) and be sure you add
.gitignore to the repository.
touch .gitignore will work in other OSes that use the bash shell (i.e., most Linux and Mac systems).
The first time you run git, it may get angry with you because you haven't configured your email and name. Just do what it says, or if you want to be proactive, open a command line interface and enter:
git config --global user.name "Your Name" git config --global user.email "email@example.com"
–global option will add the information to your global git profile so all new projects will use that information. You don't have to set a global
user.email, but things are a lot simpler if you do.
There are more settings you can configure documented here.
To make git ignore a specific file:
To make git ignore all files with a
To make git ignore all files in a directory called foo:
Comments begin with a
# Ignore all files in directory foo foo/*
You can use as many entries as you need:
# Ignore specific files nastyfile.txt another-nastyfile.docx # Ignore compiled file(s) *.exe *.o # Ignore all files in directory foo foo/*
To change directories in bash:
~ is a shortcut to your home (User) directory. So you could for example:
To navigate up one level:
To list all the files (including hidden files) in a directory:
To create a new file