Tue Dez. 5
Git Workshop 2
9 – 12h Teaching
Simon Eugster
Goals
- I can create and merge branches
- I can explain what a feature branch is used for
- I can submit pull requests and resolve them
Recap Branches. Intro forks and pull requests
First steps:
- Accept invitation for powercoders-002 repository
- Install WebStorm
First fork
Why? Contribute to other repository without having access to it. Or, as backup.
Clone https://github.com/Granjow/country-languages-exercise. Add own remote and push.
- Random pairs fork each other’s repository. Creates a completely independent own repo.
- Create a feature branch like
feature/country-names
and push country names - Create pull request on fork.
Put own repo online
Does not work with a GUI, therefore we learn command line
- Create own directory in
/var/www/html
- Clone own repository in there
- Navigate to `http://IP/user/repo
Theory/Recap: Shell commands
First conflict
Repeat for CSS, but both change it
- Owner changes background colour of box on
master
- Contributor changes box to
display: inline-block
onfeature/css
Both push. Contributor creates pull request.
- Contributor needs to update branch from upstream (add origin and rebase or merge)
- Contributor pushes again with
--force
Theory: What causes the conflict in terms of commits?`
Work on same project
Typical for projects. Everybody can push.
Put project online on a server.
- Feature branches to assign to issues
- Merge requests for master + code review to maintain quality
- Clone https://github.com/power-coders/powercoders-002
- Create a new issue for own page
- Add own page on feature branch and push
Another person (9 to the left for 18 people) reviews request.
- Create merge request, mention issue with
closes #42
- Code review: Also added to coders page? Links work?
- Merge or decline
Work on same branches
Integrate changes of other coder or of yourself (private repo, different PCs).
Theory: Rebase vs. Merge
- Take a task
- Work on a feature branch together
- Pull changes with
--rebase
Commit-Message anpassen (amend) vor Push, oder Commit rückgängig machen
Bonus Topics
Other GUIs
- GitKraken
- SmartGit
Amend commits
git commit --amend
to change commit message and add more filesgit reset --hard HEAD^
or--soft
to undo commitgit rebase -i HEAD~2
to change last 2 commits if not pushed or own branch (force push)
Outro
- Work on “Learning Git Branching” by yourself: https://learngitbranching.js.org/
- Tipp10: 5 min per day
- Security Hermi, Dec 14th: Be kind and curious
12 – 13.30h Lunch
13.30 – 17h Coaching
- Markus Koller
- Matteo Patisso
- Davide De Giorgo