Worksheet Day 2 - Version control
This worksheet includes a simulation exercise of basic Git commands to understand the Git logic (Lab Session I); installing, linking and setting up all required software and workflow (Lab Session II); and collaborate in teams on coding challenges to familiarize ourselves with the Git version control system and key Git operations, including branching, merging, forking, and resolving merge conflicts (Lab Session III).
Lab Session I 👩💻 👨💻
Simulation to learn using basic Git commands
- Try to complete the online exercises to understand the git logic:
- Main: Introduction Sequence
- Remote: Push & Pull – Git Remotes!
🎁 Bonus
- Main: Ramping Up
- Main: Moving Work Around
- Main: A Mixed Bag
- Remote: To Origin And Beyond – Advanced Git Remotes!
Instructions: Git Installation
Windows
I. 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 pressEnter
) - Type the following line into the command prompt window exactly as shown:
setx HOME "%USERPROFILE%"
. - Press
Enter
, you should seeSUCCESS: Specified value was saved
. - Quit command prompt by typing
exit
then pressingEnter
.
- This will provide you with both Git and Bash in the Git Bash program.
Mac
The default shell in some versions of macOS is Bash, and Bash is available in all versions, so no need to install anything. You access Bash from the Terminal (found in
/Applications/Utilities
). See the Git installation video tutorial for an example on how to open the Terminal. You may want to keep Terminal in your dock for this workshop.To see if your default shell is Bash type
echo $SHELL
in Terminal and press theReturn
key. If the message printed does not end with ‘/bash’ then your default is something else and you can run Bash by typingbash
.If you want to change your default shell, see this Apple Support article and follow the instructions on “How to change your default shell”.
Source: https://github-pages.ucl.ac.uk/2022-09-19-UCL-DaSH/.
Lab Session II 👩💻 👨💻
Installation is half the battle!
Create a GitHub Account. Careful when choosing your username.
Install git and GitHub Desktop if you have not done so yet. Instructions.
🎁 Bonus
Sign up for a free GitHub Pro account if you are a student or a free GitHub Team account if you are a teacher.
Connect RStudio to Git and GitHub.
Familiarise yourself with basic shell commands
Lab Session III 👩💻 👨💻
Working with GitHub
Let’s get started with creating and using your first repository. 💩 got real! 😱