Setting Up Git Workspace
####Restart Git Bash or your terminal
Once you’ve completed the following instructions, you'll need to close and re-open Git Bash (if you are using Windows) or your terminal (if you are using Mac or Linux). Many of the configurations listed here will not take place until you have done this, so if you don’t see your changes taking place right away, this is probably why.
####Downloading necessary files
Later in these instructions, you'll need the two files git-completion.bash
and git-prompt.sh
. To download them:
git-completion.bash
.git-completion.bash
using the command line. (Some browsers will name the file git-completion.bash.txt
.)git-prompt.sh
in your home directory.####Creating a .bash_profile
Some of the following configurations will require you to add to a file called .bash_profile
, which is used to configure Git Bash if you’re using Windows, or the terminal if you’re using Mac or Linux. (If your terminal is using a different shell than bash, than many of the following instructions will not work. However, bash is the default on both Mac and Ubuntu.) Note: Since this file has a period at the beginning of its name, it is called a hidden file and will not appear in most file system navigators. To create this file:
.bash_profile
ls -a
, which shows hidden files, to confirm your file has been created.####Setting up tab completion
Setting up tab completion allows you to type the first few characters of a Git command, press tab, and have the rest of the command filled in. Having tab completion set up can make working with Git much more efficient.
To set up tab completion:
git-completion.bash
.source git-completion.bash
to your .bash_profile
.####Configuring your name and email
When you used git log
earlier, you saw that Git listed the author of each commit. In order to do this, Git needs to know your name and email address. In fact, Git will not allow you to commit before you’ve given it this information. To do so:
git config --global user.name "Your name"
git config --global user.email "youremail@domain.com"
Fill in your own name and email address where indicated.
####Set up a default editor
Sometimes Git will automatically open a text editor. For example, if you make a commit without specifying a commit message, Git will open a text editor and allow you to use it to write the commit message. You’ll want this editor to be one you like. To configure which editor Git will open:
git config --global core.editor
, followed by the command you run to start your editor.For example, if you use Sublime, you would run git config --global core.editor "subl -n -w"
.
####Restart Git Bash or your terminal
Don’t forget to do this, or some of your changes won’t take effect.