This is an old revision of the document!
Table of Contents
Git tips
Initial configuration
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 you@example.com
The –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.name
and user.email
, but things are a lot simpler if you do.
There are more settings you can configure documented here.
.gitignore
To make git ignore a specific file:
- .gitignore
nastyfile.txt
To make git ignore all files with a .exe
extension:
- .gitignore
*.exe
To make git ignore all files in a directory called foo:
- .gitignore
foo/*
Comments begin with a #
- .gitignore
# Ignore all files in directory foo foo/*
You can use as many entries as you need:
- .gitignore
# Ignore specific files nastyfile.txt another-nastyfile.docx # Ignore compiled file(s) *.exe *.o # Ignore all files in directory foo foo/*
Bash tips
To change directories in bash:
cd {path-to-directory-using-forward-slashes}
~ is a shortcut to your home (User) directory. So you could for example:
cd ~/Documents/Dev/MyProject
To navigate up one level:
cd ../
To list all the files (including hidden files) in a directory:
ls -la
To create a new file
touch {filename}
Tips for Windows users
On Windows, use Git Bash (In Explorer, right click and Git Bash Here) to run git commands.
To create a .gitignore
file in Windows, open Git Bash in your project directory and enter
touch .gitignore
This will work in the command line interface on other OSes as well. If you try to create a .gitignore
file using Window's Explorer, Windows will get angry with you. However you do it, be sure the file you create is called .gitignore
and not .gitignore.txt
or similar and be sure you add it to the repository.