Git Overview
What is Git/Github and why do I want to use it?
Git is a version control system. It lets you track changes to your code and documents over time, so you can:
- Organise your work: keep your research projects, analysis scripts, and data files tidy and structured.
- Track changes: see what was added, removed, or modified, and go back to previous versions if something breaks.
- Collaborate safely: multiple people can work on the same project without overwriting each other’s work.
GitHub is a cloud-based platform that works with Git. It lets you:
- Share your projects with others, or download packages and code that other researchers have shared.
- Collaborate on code and projects with colleagues or contributors around the world.
- Create webpages and reports using tools like Quarto (we’ll cover this in part two of the workshop).
- Host and publish your work online, making it easier to share and document your research reproducibly.
In short: Git keeps your work organised and versioned on your local computer, and GitHub lets you back it up, share it, and collaborate with others online.
- The Kākāpō genome project, with all the scripts and workflows needed for the genome assembly.
- The website for the Genomics Aotearoa Bioinformatics Training Programme is hosted on github, written in Quarto and displayed using github pages.
- A curated list of awesome ggplot2 packages
Setup on local machine
We will run everything locally in RStudio. If you are confident using the command line, you could also use any command line shell you like instead (e.g., Terminal (macOS), Warp, GitBash for Windows, Visual Studio Code). Please have the following installed before the workshop.
If you already have these tools installed, make sure they are up to date.
1. Install the latest version of R
- Mac: Download
.pkg
installer here
- Windows: Download
.exe
installer here
- Linux: Instructions here
Note: Do not use
.tar.gz
source files unless you want to compile R from source.
2. Install the latest version of RStudio
3. Install Git
Git is a separate program from R/RStudio.
- Mac: Check if Git is already installed. Open terminal and run:
git --version
Note: If it is not already installed, follow instructions here for macOS
- Windows: Follow the “Installing Git for Windows” instructions here on the software carpentry page (Instructions may be hiding under “The Bash Shell” section, tab for “Git for Windows”.)
Installing Git for Windows
If you are unable to use WSL 2, please use the following instructions to install Git for Windows (“Git Bash”).
- Download the Git for Windows installer.
- Run the installer and follow the steps below:
- Click on “Next” four times (two times if you’ve previously installed Git). You don’t need to change anything in the Information, location, components, and start menu screens.
- From the dropdown menu, “Choosing the default editor used by Git”, select “Use the Nano editor by default” (NOTE: you will need to scroll up to find it) and click on “Next”.
- On the page that says “Adjusting the name of the initial branch in new repositories”, ensure that “Let Git decide” is selected. This will ensure the highest level of compatibility for our lessons.
- Ensure that “Git from the command line and also from 3rd-party software” is selected and click on “Next”. (If you don’t do this Git Bash will not work properly, requiring you to remove the Git Bash installation, re-run the installer and to select the “Git from the command line and also from 3rd-party software” option.)
- Select “Use bundled OpenSSH”.
- Ensure that “Use the native Windows Secure Channel Library” is selected and click on “Next”.
- Ensure that “Checkout Windows-style, commit Unix-style line endings” is selected and click on “Next”.
- Ensure that “Use Windows’ default console window” is selected and click on “Next”.
- Ensure that “Default (fast-forward or merge) is selected and click”Next”
- Ensure that “Git Credential Manager” is selected and click on “Next”.
- Ensure that “Enable file system caching” is selected and click on “Next”.
- Click on “Install”.
- Click on “Finish” or “Next”.
- If your “HOME” environment variable is not set (or you don’t know what this is):
- Open command prompt (Open Start Menu then type
cmd
and press Enter) - Type the following line into the command prompt window exactly as shown:
setx HOME "%USERPROFILE%"
- Press Enter, you should see SUCCESS: Specified value was saved.
- Quit command prompt by typing
exit
then pressing Enter
- Open command prompt (Open Start Menu then type
This will provide you with both Git and Bash in the Git Bash program.
Note: If you have previously completed the carpentries lesson on Introduction to Shell on your windows computer, you would have already downloaded Git.
4. Make a Github account
- Go to https://github.com and follow the “Sign up” link at the top-right of the window.
- Follow the instructions to create an account.
- Verify your email address with GitHub.
- Configure multifactor authentication (see Github page on 2FA)
- Optional: Add a profile picture and modify other preferences, such as linking ORCID, in your github account.