# COMP0233 - Day 2 (13th October 2022)
:::info
## :tada: Welcome to the second day!
### Today
Today we will
- How to collaborate to the same repository
- Learn about problems you may face using git
- Explore the parallel universes functionality
- Contribute to repositories that you don't have permissions to
:::
:::danger
Remember to `rename` yourself by clicking on your zoom name (in the participants list) and change it to:
`SXXX` where XXX is the room number (105, 121 or 406) or 000 for the online attendees.
If you disconnect and connect again, please rename yourself again.
:::
### Review from last week
- Why using version control
- How to create a git repository locally
- How to revert commits
#### What was discussed during the week :newspaper:
- groups and timetabling: Class every week for everyone.
- `git init` on a home or desktop directory
- [SSH keys](/FMnWK53aRz6BcFA3DOR7ZA) (cloning using https or ssh)
- Conflicts - we will learn how to solve them today!
:::spoiler Whatsapp and WeChat group
https://chat.whatsapp.com/FZjR4dzAL4D5xVOdENqCJR

:::
:::warning
Avoid sharing code through it. Use github or something more code-friendly!
:::
### Uploading last week repository into 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 (make sure you are using the ssh option)
- 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
```
:::spoiler Have you missed last week?
Import the family recipes repository under your user name following these steps:
1. Go to the [import repository page on github](https://github.com/new/import)
2. add the repo url: `3. https://github.com/arc-teaching/family_reci`es
4. add the repo name under your user-name: family_recipes
5. press <kbd>Begin Import</kbd>

5. Go to the page of the new imported repository `https://github.com/YOURUSERNAME/family_recipes`
6. Clone that repository locally using ssh:
```bash
cd Desktop
git clone git@github.com:YOURUSERNAME/family_recipes
```
:::
### Groups :handshake:
We will be working in pairs, in class with the person next to you, in zoom via breaking rooms.
:::warning
- :question: What is one simple thing you do (or you are planning to do) to fight climate change and help saving our :earth_asia::earth_africa::earth_americas: ?
**Write** [your topic on mentimeter](https://www.menti.com/aljws4y6srpr) and describe it shortly whitin your group.
- :exclamation: Decide who will be :A:nne and who :B:ernie
:B:ernie **writes** their github name and family_recipes repository invite link on the [List of gh usernames](/UeSsz1LUTLSaQlCyO_QYzQ), :A:nn **adds** their gh name at the end of that line.
:::
### More than one file
1. create a base for pizza, and
1. update the index.
1. commit two files to the repository
### Collaboration
Look at your lists.
| person :A: | person :B: |
| ------------ | ----------- |
| write your GH username after your name | |
| | Add GH user name from :A: as collaborator |
| | Give to person :A: a link to the invitation |
| Accept invitation of :B: | |
| Go to your desktop and clone the repository of :B: with `git clone <url> <nameB>_recipes`| |
| Add a new file to :B: repository and push ||
| | Pull the changes produced by :A:|
| :heavy_check_mark: | :heavy_check_mark: |
### Problems when collaborating :left_right_arrow:
| person :A: | person :B: |
| ------------ | ----------- |
| Change `family` for `clan` | Change `secret` for `mysterious` |
| Commit and push | Commit and push |
| | Got an error |
:::info
:cloud: Question (mentimeter): Why did :B: get an error trying to push?
:link::arrow_right: [Describe it in one or two words](https://www.menti.com/aljws4y6srpr)
:::
### Forks :trident:
Adding collaborators is not a scalable solution.
Forks provide an easier way to contribute
:::info
Let's fork the repository for classwork of the course
[`RSE-Classwork`](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/)
[:hash::one:](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/issues/1)
:::
### Branch :twisted_rightwards_arrows:
[Simulator](http://git-school.github.io/visualizing-git/)
:::spoiler Commands for the simulator
|action| new git | old git |
|--- | --- | ---|
|Create a branch and jump to it |`git switch -c <branchname>`| `git checkout -b <branchname>`|
|Jump to an existing branch | `git switch <branchname>` | `git checkout <branchname>`|
:::
:::info
[`RSE-Classwork`](https://github.com/UCL-COMP0233-22-23/RSE-Classwork)
[:hash::two:](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/issues/2)
:::
### Conflicts :dizzy_face:
Now that we know about branches... let's create a conflict using them.
How we can solve conflicts? Try it first
:::info
[`RSE-classwork`](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/)
[:hash::three:](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/issues/3)
:::
### Stashing :card_file_box:
Why do we need it?
### Pull Request ⛙
:::info
[`RSE-classwork`](https://github.com/UCL-COMP0233-22-23/RSE-Classwork)
[:hash::four:](https://github.com/UCL-COMP0233-22-23/RSE-Classwork/issues/4)
:::
### Extra resources
- [Git and Github crash course](https://www.youtube.com/watch?v=RGOj5yH7evk) - FreeCodeCamp.org 1h video about everything we've seen.
# What you need to do next
## :one: Finish the exercises
## :two: Early module feedback questionnaire
[Moodle :eyes: ](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=4462915)
## :three: Getting ready for next week
Next week we start with Python
- Read the material,
- Solve some quizzes in moodle, and
- participate in some discussions
## Office hours
- [Let us know your preferred times](https://moodle.ucl.ac.uk/mod/questionnaire/view.php?id=4462879), and
- [Book a slot](https://moodle.ucl.ac.uk/mod/url/view.php?id=2572664)
# Questions
:::info
Feel free to add any question below. Remember the syntax:
```
- Example question
- [name=student_a] Example answer
- [name=TA_1] Example answer
```
:::
- .
- [name=...]
- .
- [name=...]
- .
- [name=...]
###### tags: `COMP0233` `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