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:

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.

  1. Random pairs fork each other’s repository. Creates a completely independent own repo.
  2. Create a feature branch like feature/country-names and push country names
  3. Create pull request on fork.

Put own repo online

Does not work with a GUI, therefore we learn command line

  1. Create own directory in /var/www/html
  2. Clone own repository in there
  3. 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 on feature/css

Both push. Contributor creates pull request.

  1. Contributor needs to update branch from upstream (add origin and rebase or merge)
  2. 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
  1. Clone https://github.com/power-coders/powercoders-002
  2. Create a new issue for own page
  3. Add own page on feature branch and push

Another person (9 to the left for 18 people) reviews request.

  1. Create merge request, mention issue with closes #42
  2. Code review: Also added to coders page? Links work?
  3. Merge or decline

Work on same branches

Integrate changes of other coder or of yourself (private repo, different PCs).

Theory: Rebase vs. Merge

  1. Take a task
  2. Work on a feature branch together
  3. 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 files
  • git reset --hard HEAD^ or --soft to undo commit
  • git rebase -i HEAD~2 to change last 2 commits if not pushed or own branch (force push)

Outro

12 – 13.30h Lunch

13.30 – 17h Coaching

  • Markus Koller
  • Matteo Patisso
  • Davide De Giorgo

Continue working on your focus goals

Groups & Technologies can be found here