This document discusses how learning and using Git can make a developer's life easier. It begins with an introduction to Git and its origins. It then covers the basics of commits, branches, and common workflows like centralized, feature branch, and Gitflow. It also addresses resolving merge conflicts. The key takeaways are that Git allows for version control and collaboration, learning it incrementally and through practice is best, and different workflows suit projects of varying sizes. Teaching Git to others requires patience and using real examples.
OSMC 2022 | Git Good – How knowing git can make your life easier by Feu Mourek
1. How knowing git can make
your life easier
by Feu Mourek
Git Good
2. Feu Mourek (they / them)
Developer at Netways 2016 to 2020
Developer Advocate at Icinga from 2020
Git / GitLab Trainer since 2019
Passionate about:
Teaching, Accessibility,
Inclusiveness, Old Cars
My Twitter is @the_feufeu
3.
4. Agenda
1. Learning about Git
2. Working with Git, instead of around
3. Which workflow fits you?
4. Sharing this knowledge
5. Learning Git
- What is Git?
- Where does it come from?
- Start small, understand, move on
- Practice on CLI
- Do I really need to know all of these commands?
6. What is a commit?
- Think of it as snapshots
- Only saves differences to the last commit
- Contains general meta information
- Author
- Time
- Message with description and references
- Pointer to previous commit
- One of many point in the projects history
7. Good Commits
- Configure your name and email
- One commit contains one topic
- If needed split your commits
- Make your commit messages short and precise
- Add references if you can
- Use the staging area:
8. The Three Stages
- Working directory: files on your filesystem
- Staging area: file states saved by git
- Repository: snapshots of points in history
Only Repository will be synchronised with the server
9. Git Branches
- Allow free switching between different states of the project
- Different features can be developed simultaneously
- Different branching models allow for a smooth development workflow
17. Centralised Workflow
- Small projects (1-3 Developers)
- Working on a single branch
Pros:
- Very simple
- Very fast
Cons:
- Many conflicts
- Possibly broken code in main
18. Feature Branch Workflow
- Medium projects (up to 30 Developers)
- Main branch only contains completed features
- Features completed in own branches
- Feature branches work like Centralised Workflow
19.
20.
21.
22.
23.
24.
25.
26. Feature Branch Workflow
- Medium projects (up to 30 Developers)
- Main branch only contains completed features
- Features completed in own branches
- Feature branches work like Centralised Workflow
Pros:
- Stable main
- Less interference with others
- Good for reviews
Cons:
- Communication about features
- No release ready main
27. Gitflow Workflow
- Large projects
- Extended Feature Branch Workflow
- More complexity and nuance
28.
29.
30.
31.
32. Gitflow Workflow
- Large projects
- Extended Feature Branch Workflow
- More complexity and nuance
Pros:
- Very organised
- Permission oriented
- Easy automation
Cons:
- Very complex
- Needs people to overlook the
processes
34. Merge Conflicts
$ git merge new_branch_to_merge_later
Auto-merging merge.txt
CONFLICT (content): Merge conflict in merge.txt
Automatic merge failed; fix conflicts and then commit the
result.
35. Merge Conflicts
$ cat merge.txt
<<<<<<< HEAD
this is some content to mess with
content to append
=======
totally different content to merge later
>>>>>>> new_branch_to_merge_later
36. Merge Conflicts
$ git add merge.txt
$ git commit -m "merged and resolved the conflict in
merge.txt"
37. Merge Conflicts
$ cat merge.txt
<<<<<<< HEAD
this is some content to mess with
content to append
=======
totally different content to merge later
>>>>>>> new_branch_to_merge_later
38. How to teach Git
- Git is complex, take it step by step
- If there is a question, solve it together
- The official documentation is super useful
- Explain with real world examples
- Your search engine is your friend!
39. Thanks for being here with me!
Twitter
@the_feufeu
GitHub Repo
github.com/NETWAYS/gitlab-training
Trainings
netways.de/en/trainings