Chapter 2 Setup
When we use Git on a new computer for the first time, we need to configure a few things. This should not take a great deal of time.
2.1 Registration and installation
To get going you firstly need to register for a free a public account on GitHub by going to the website:
If you want to keep your account private on GitHub then you are going to need to pay a nominal fee. The alternative is to use one of the other repositories such as BitBucket.
Thereafter you need to install Git on your computer. The two major options are:
Both of these programs are freeware and I’ve installed both of them, since I prefer the Git Shell in “GitHub Desktop for Windows” (which allows you to copy and paste), while “Git for Windows” is much better at communicating with RStudio.
2.2 Getting started
It is usually a good idea to get started with the help of the Git Shell, which should open as a terminal application. Note that the changes that you make during this session can be updated or changed at a later point in time by using the same commands.
To get started with Git we need to provide it with a few details relating to:
- your name and email address,
- your colour preferences for output,
- your preferred text editor (for this overview),
On a command line in the terminal, Git commands are written as a git verb, where verb
is the activity that we want to undertake. By way of example, this is how I would configure an account for a new computer:
> git config --global user.name "Kevin Kotze"
> git config --global user.email "kevinkotze@gmail.com"
> git config --global color.ui "auto"
Please use your own details to configure your account. This user name and email address will be associated with all your subsequent Git activity, for any changes pushed to GitHub, BitBucket, GitLab or any other Git host server. Note also that the email address used should be the same as the one used when setting up your GitHub account.
You should also set your favorite text editor to one of the following:
Editor | Configuration command |
---|---|
Atom | > git config --global core.editor "atom --wait" |
nano | > git config --global core.editor "nano -w" |
Text Wrangler (Mac) | > git config --global core.editor "edit -w" |
Sublime Text (Mac) | > git config --global core.editor "subl -n -w" |
Sublime Text (Win, 32-bit install) | > git config --global core.editor "'c:/program files (x86)/sublime text 3/sublime_text.exe' -w" |
Sublime Text (Win, 64-bit install) | > git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w" |
Notepad++ (Win, 32-bit install) | > git config --global core.editor "'c:/program files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" |
Notepad++ (Win, 64-bit install) | > git config --global core.editor "'c:/program files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" |
Kate (Linux) | > git config --global core.editor "kate" |
Gedit (Linux) | > git config --global core.editor "gedit --wait --new-window" |
Scratch (Linux) | > git config --global core.editor "scratch-text-editor" |
emacs | > git config --global core.editor "emacs" |
vim | > git config --global core.editor "vim" |
By making use of the flag --global
it will tell Git to use these settings for every project, in your user account on this computer.
To check your settings, which can be done at any time, just make use of the command:
> git config --list
2.3 Help and manual
Always remember that if you forget a Git command, you can access the list of command by using -h and access the Git manual by using –help :
> git config -h
> git config --help