Git is a version control system that lets you track who made changes to what when and has options for easily updating a shared or public version of your code on source code repository hosting platforms such as GitHub or GitLab or Bitbucket. You will need a supported web browser (current versions of Chrome, Firefox, Safari, or Internet Explorer version 9 or above).
You will need an account at GitHub for parts of the Git lesson. Basic GitHub accounts are free. We recommend you to create a GitHub account if you don’t have one already. Please consider what personal information you’d like to reveal. For example, you may want to review these instructions for keeping your email address private provided at GitHub.
If you do not wish to use GitHub and a corresponding account, you can instead use your favourite source code repository hosting platform. Most aspects of our material and exercises are transferable to all popular platforms.
Follow the installation instructions below but do not forget to also configure Git.
Conda can be used to install Git on Linux, macOS and Windows computers. To install Git without conda, please follow the instructions in the following sections.
To install Git with conda, you need to have installed Anaconda or Miniconda. Then you can install Git in one line in the Anaconda prompt (on Windows) or in a terminal (macOS and Linux):
$ conda install git
On Windows, this will guarantee that you can use both Git and Python and Anaconda scripts in the same (conda) environment.
If Git is not already available on your machine you can try to install it via your distribution package manager.
For Debian/Ubuntu run:
$ sudo apt-get install git
Check the version after installing:
$ git --version
$ sudo dnf install git
Install Git for Mac by downloading and running the most recent “mavericks” installer from this list.
After installing Git, there will not be anything in your
folder, as Git is a command line program.
Use the most recent available installer labelled “snow-leopard” available here.
In this case Git should be installed on your computer as part of the Bash installation.
Possible problem with this approach is that Git Bash does not see the Python and Anaconda scripts. See also the troubleshooting page.
$ git clone https://github.com/coderefinery/recipe.git testing-git-clone $ cd testing-git-clone $ git log --oneline
You should see something like this:
40fbb90 (HEAD -> master, origin/master, origin/HEAD) draft a readme dd4472c we should not forget to enjoy 2bb9bb4 add half an onion 2d79e7e adding ingredients and instructions
Please also check that you can access Git and Python in the same environment by checking the versions of pytest and sphinx-build (not a problem if versions differ a bit):
$ pytest --version This is pytest version 5.2.1 $ sphinx-build --version sphinx-build 2.2.0
After signing up for a GitHub account and installing Git on your machine, you should go through the following steps to configure Git. First, the following commands will set your user name and email address:
$ git config --global user.name "Your Name" $ git config --global user.email email@example.com
This is important since your Git commits use this information.
--global option ensures that you do not need to enter this information again on your machine.
It is convenient to set also the default text editor to use with Git. You can replace nano with vim, emacs or any other editor of your choice:
$ git config --global core.editor nano
If you are on Windows and want to use Notepad or Notepad++, you can configure this by providing the full path to the executable and optionally set some options. For example (adjust the path if needed, and note the quotation):
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
To see where this information is stored, use:
$ git config --list --show-origin
Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.
If you are unsure about this, you can skip this part and authenticate with GitHub using your username and password every time you will push changes to GitHub.
If you decide to set up SSH keys, follow this guide to connect to GitHub with SSH keys.