# MPHY0021 - Day 1 (7th October 2021)
:::info
## :tada: Welcome to the first day!
MPHY0021
### Today
Today we will have a
- short introduction about the what's we will be covering in this course and how to use the tools we need, and
- an introduction to version control with Git.
:::
### :stopwatch: Time keeper
- [name=Thomas R] :raised_hand: 5' before the end of each block.
- 10:00 - 10:50
- 11:05 - 11:55
- 12:05 - 12:55
### Course and tools
#### Tools
- [Introduction to Zoom](/g3UdAivaRg-qJjmf0E_StQ)
- [Introduction to HackMD](/LMK0i9QQTiuaWanyKcRBtQ)
- We will also use [GitHub][gh] - [create an account **now**][gh-account] if you've not done it already.
- You will need to [set ssh keys](/FMnWK53aRz6BcFA3DOR7ZA) to be able to use it during the course.
#### Course
- [Introduction to MPHY0021](/1JQyi7gmQviK8DMNmqUdXg)
### Groups
We will be using the breaking rooms functionality of Zoom.
We have the following groups, and each group have its own document
Today, as we don't know which :e-mail: you used to connect, we will assign groups randomly.
Once in your breakout-room, find who is chairing that room and open the document linked to that group.
:::danger
Once you are in the breakout room and you know in which group you are in, click `rename` on your zoom name (in the participants list) and change it to:
`SGX - Your name` being `X` the number of the group you have been assigned to.
:::
- [Group 1: David](/6AbGEpIuQ4OFbgHZj9GXpA)
- [Group 2: Anastasis](/ZZGMZE1tSAaPpB0_3fxCAw)
- [Group 3: Nisha](/uDIu727VSUuz_hGroxKGmQ)
- [Group 4: Stef](/oWoiQcvuQee6bcbnMk9aMQ)
- [Group 5: Matthew](/4RQMPMFVRdGkxzMoYF0jyQ)
- [Group 6: Alessandro](/znv7flyZT6qCSQX2u5qJaQ)
- [Group 7: Matt](/WY-Fc_PvQUS5d1K-UotLBQ)
### Git
#### Group Discussion 1: Why we need a version control system?
In your groups discuss this image and write your conclusions about why a VCS is useful.

#### Discussion comments
- group 1:
- The student is using a version control system but not too efficent
- This kind of scenario arises because of wishful thinking - not anticipating the complicated trajectory that the project will take, and just hoping/expecting it will all go smoothly.
- It is important for the VCS to track what the significance of the different versions is - not just to have arbitarily named versions, or timestamped versions - so that you can identify which previous version you are looking for.
- group 2:
- Collaboration
- Keep track of changes made
- To back up the work that has been done
- Alternate versions
- For small or large projects
- group 3:
* Collaboration - Important to keep track of different changes people make when working within a group
* The above shows how hard it is to keep track of which changes have been made with different file names
* VCS is useful if you wanted to go back to a particular version in history
* With VCS you can also backup/retrieve your files/project from github
- group 4:
* Keeping track of collaborative document - see latest version!
* Documenting changes, so we know who to blame :) or thank.
* Previous strategies include: Storing docs in specific folders for certain contributors. Compare to "main" doc.
* Benefits of git-style version control: Seeing contrasting suggestions to "improve" - everyone can see the same thing.
- group 5:
* naming files adding more and more stuff, gets overwhelming.
* consistent naming is an issue, not logical.
* Click interface for git in class work
* Undergraduate group project, add new version to git to always get new version.
* A backup or two of previous two versions. Named it backup1... and backup2..., to make sure can access a previous version.
- group 6:
* ability to go back to previous version
* people can collaborate on the same document
* safety of main version when trying to add new features
* easy to have an overview of all versions and how they're connected
* learn to be organised/practice being organised
* enforces modularity and thinking in small updates
- group 7:
* Can be used to backup files in a project to allow us to recover previous versions
* Allows multiple people to collaborate on same project simultaneously or one person to work on various parts (mention of experience of using branches)
* Tools like GitHub, Bitbucket allow us to work collaboratively and synchronize files across multiple computers
#### Introduce ourselves to git
Follow live coding using a git bash (windows) or a terminal (Mac/Linux).
:::warning
If you are unfamiliar with the bash shell, you can learn about it going through the [Software Carpentry's introduction to the Unix shell](https://swcarpentry.github.io/shell-novice/).
You have also got access to courses in:
- LinkedIn Learning: [Learning Linux Command Line](https://www.linkedin.com/learning/learning-linux-command-line-2/learning-linux-command-line?u=69919578) (check Chapters 2-4)
- O'reilly Learning: [Linux Command Line for Beginners](https://learning.oreilly.com/videos/linux-command-line/9781771374446/) (Chapters 1-4)
If you are unfamilliar with git:
- Go through our [course notes on git](http://github-pages.ucl.ac.uk/rsd-engineeringcourse/ch02git/) (also linked on moodle)
- You can learn learn more through the [Software Carpentry's Version Control with Git](https://swcarpentry.github.io/git-novice/)
:::
First try
`git config --list` Do you get an output?
No?
```bash
git config --global user.name "Your Name"
git config --global user.email "your_email@email.com"
git config --global core.editor "nano -w"
git config --global init.defaultBranch "main"
```
#### Create a repository
```bash
pwd # Note where we are standing-- MAKE SURE YOU INITIALISE THE RIGHT FOLDER
cd Desktop/
mkdir family_recipes
```
```
cd family_recipes
git init
```
#### Creating recipes
```bash
nano index.md
```
contents of `index.md`:
```
# Family secret recipes
Set of recipes as given by my grandma.
```
```bash
git add index.md
git commit -m "Setting up the title for the book"
```
running `git status` should say `...nothing to commit, working tree clean`
running `git log` will have the single commit
##### Visual studio code
adding and committing:
- File > Open Folder ... `family_recipes`
- Left hand side can see the index.md file, can open it and edit it :
- contents of `index.md`:
```
# Family secret recipes
Set of recipes as given by my grandma.
- pizzas (TODO)
- sauces (TODO)
- spreads (TODO)
```
- Source Control/branch icon shows that a single file is modified
- click on the Source Control icon
- files have 4 icons in this panel: open file / discard changes / stage changes (i.e. git add) / state of file
- click stage changes icon -> the file is now in the `staged changes` section
- Type in the commit message above the staged changes.
- `Ctrl + Enter` or click check mark to commit
git log (requires git graph extension, install it if you don't have it):
- click on graph icon to the right of where the git commit check mark is
- Can explore the commit information, click on the file to see side by side differences that were made to the file
##### making mistakes
- update index.md to have mistakes:
```markdown=
# Family secret recipes
Set of recipes as given by my grandma.
- pizas (TODO)
- sauses (TODO)
- reads (TODO)
```
- save file, stage and then commit the file, which has some typos
- Now make a change that is valid
```markdown=
# Perez's Family secret recipes
Set of recipes as given by my grandma.
- pizas (TODO)
- sauses (TODO)
- reads (TODO)
```
- save file, stage and then commit the file
- Go to git graph and view the commits
- revert the previous commit at the command line by doing one of the following, (edit the commit message if you'd like and exit the editor):
- `git revert HEAD^`
- `git revert HEAD~1`
- `git revert <commit hash/barcode>`
- current state of `index.md`
```markdown=
# Perez's Family secret recipes
Set of recipes as given by my grandma.
- pizzas (TODO)
- sauces (TODO)
- spreads (TODO)
```
#### github
- log in to [github][gh]
- click create a [new repository][gh-new]
- make the repository name `family_recipes`
- don't tick any of the options boxes
- click the create repository button
- copy the github url (can be either the shh if you've set this up, or https if not)
- add the github url as the remote and push local changes to github
```
git remote add origin <github url>
git branch -M main
git push -u origin main
```
# Next week
We will learn:
- How to merge conflicts,
- Git branching, and
- better strategies about collaborating with others.
# Questions
Here you can post any question you have while we are going through this document. A summary of the questions and the answers will be posted in moodle after each session. Please, use a new bullet point for each question and sub-bullet points for their answers.
For example writing like this:
```
- Example question
- [name=student_a] Example answer
- [name=TA_1] Example answer
```
produces the following result:
- Example question
- [name=student_a] Example answer
- [name=TA_1] Example answer
Write new questions below :point_down:
- [name=student_a] Example answer
- [name=TA_1] Example answer
- Q1.Where/how do we send person 1 the invitation link?
- [name=Umit] I have paste my link next to my name in group breakour hackmd. That might be way to share I guess
- [name=Anastasis] We'll go over that when the time comes :smiley:
###### tags: `mphy0021` `teaching` `class`
[gh]: https://github.com/
[gh-account]: https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F&source=header-home
[gh-new]: https://github.com/new