# CodeRefinery workshop with CoSMo/UiT
###### tags: `workshop`
:::info
- Questions and notes (this document): https://hackmd.io/@coderefinery/cosmo-2022
- To write, click on the :pencil: (Edit) icon on the top right corner and write at the bottom, above the ending line. If you experience lags, switch back to "view mode" ("eye" icon)*
- Video connection: shared via email
- Lesson material (will change up to the course):
- https://coderefinery.github.io/git-intro/
- https://coderefinery.github.io/git-collaborative/
- **What you need to install/prepare**
- [Shell and Git](https://coderefinery.github.io/installation/shell-and-git/)
- [GitHub account](https://coderefinery.github.io/installation/github/)
- [SSH connection to GitHub](https://coderefinery.github.io/installation/ssh/)
- [We will also need a text editor](https://coderefinery.github.io/installation/editors/)
- **Contact**
- Radovan Bast: radovan.bast@uit.no (don't hesitate to ask)
- Magda Korzeniowska magdalena.a.korzeniowska@uit.no (really, don't hesitate)
:::
:::warning
**Installation session - Feb 9, 8:15 - 10:00**
- See above ("What you need to install/prepare")
- Instructor will be there to help
**Day 1 - Feb 16, 8:30 - 11:30**
- Motivation
- Commits and commit messages
- Branching, merging, and conflict resolution
- Inspecting history
**Day 2 - Feb 23, 8:30 - 11:30**
- Collaboration
- Organizing repositories and branches
- Contributing changes to somebody else's project
- What else is there
:::
## Resources
- https://coderefinery.org/
## Icebreaker
What aspect of Git is the most confusing/weird that you would like to have clarified today?
- I was never sure what happens locally or not locally, also confused about branches
- Trying to fix merge errors
## Questions
Here we will ask, answer and comment as we go along.
- When does it make sense to change a commit in retorspect instead of making a new commit?
- When the commit has not been shared and you prefer to modify it before sharing or when correcting a serious problem such as accidentally sharing a password in a commit.
- Does using git rm remove them from the system or just from the git add?
- If you instead do `git rm --cached`, it is just ignored by git, not removed from the system.
- The git add seems to be often just additional hazzle. Why does it exist?
- good point. it is ok to avoid it and `git commit <file>` directly. But please also have a look at https://coderefinery.github.io/git-intro/staging-area/ which motivates why this can be useful. We start with it to train muscle memory for later where people typically appreciate the staging area and git add-ing.
- Can you do a git commit without git add before?
- `git commit <file>`
- Perhaps a clarification is that if the file is completely new (un-tracked by git), it must be `git add <file>`-ed before committing. But if the file is already tracked and just changed, `git commit <file>` works. Below, `new.txt` is created, `ingredients.txt` is changed.
```console
$ touch new_file.txt
$ nano ingredients.txt
$ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: ingredients.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
new.txt
$ git commit new.txt
error: pathspec 'new.txt' did not match any file(s) known to git
$ git commit ingredients.txt
[main f094a97] Add pepper to ingredients
1 file changed, 1 insertion(+)
```
- How and when to use tags? In particular in relation to tags/releases on GitHub?
- GitHub releases are Git tags under the hood, plus some extra metadata such as release notes. So when you create a tag and push the tag to GitHub, it will create a release.
- Difference between `git annotate` and `git blame`?
- Same thing but the former is a better name. The latter is the traditional and unfortunate name.
- Is tere a practical problem with having my repositories on Google Drive? I am used to storing my documents and code in one place.
## How is the speed so far?
vote by adding a "o" at the end
- too slow : oo
- too fast :
- is ok : oooooooooooO
## Feedback from day 1
One thing that was particularly useful:
- ...
- Learning about branches +2
- git graph alias +1
- easily sharing repositories online
- good notes and examples
- nice hands-on course starting from the very beginning +1
- Really nice web-page (code-refinery). +1
- Screen sharing
One thing that needs to be improved:
- network
- would like even more exercises and do yourself +1
- thanks! next time more exercises
- a bit jumpy and fast in the end +2
- thanks for feedback. indeed.
- ...
## Day 2
https://coderefinery.github.io/git-collaborative/
### GitHub user names (for session #2 groupwork)
We will use this information to invite you as collaborator
to an [exercise repository](https://github.com/bast/centralized-workflow-exercise). Later we will remove the exercise repository again.
bast
makorzen
egavazzi
SamuelKo1607
kei070
Sosnowsky
gregordecristoforo
eirikmn
HenrikJantti
arostrup
auroradh
Hegebf
carla059
mto078
hummelsumm
Jullcifer
pst019
aasemari
## Exercise (collaboration inside a repo)
- repository: https://github.com/bast/centralized-workflow-exercise
- what you are asked to do: https://coderefinery.github.io/git-collaborative/centralized/#exercise-part-1-creating-a-pull-request (scroll to green box "exercise description")
## Questions
- When you use `git fetch`, are the changes from remote in the master branch or in a new branch?
- `git fetch origin` fetches all commits from `origin` and updates all `origin/something` branches but will not modify any of your local branches
- in other words one thing you could do is to first `git fetch`, then inspect the changes, then `git merge` them. `git pull` does both in one go: "=git pull = git fetch + git merge"
## Exercise repository for forking
https://github.com/bast/forking-workflow-exercise
In this repository you don't have write/push permissions and you will have to fork first.
Exercise description: https://coderefinery.github.io/git-collaborative/distributed/#exercise-part-1-creating-a-pull-request
## Feedback from day 2
One thing that was particularly useful:
- do it yourself excercises + good material
- easily understandable and exercises that help to learn and understand
- really like that all the material is still available after the workshop +1
One thing that needs to be improved:
- idea: start real world collaborations or projects we would like to continue with in our work (instead of artificial exercises)
- maybe wrap up a workshop for beginners with a short reminder on the most basic way to start using GIT in practice.
----
This is the end of the document. **Write above this line ^^**