Git & GitLab How-to
Duration1h30Introduction
This tutorial is a hands-on collaborative exercise that brings Git and GitLab concepts to life through a simple “Hello World” project. You’ll work with a classmate to experience real-world collaboration scenarios including conflicts, branching, and merge requests.
Each student plays both roles:
- 🅰️ Alice: Create and manage your own project
- 🅱️ Bob: Collaborate on your partner’s project
Now:
- Find a classmate to partner with
- Exchange GitLab usernames
- You can work asynchronously (coordinate timing via messages)
Prerequisites
Readings
You must read these comprehensive guides before starting:
- ✅ Git Fundamentals - Complete Git workflow and commands
- ✅ GitLab Platform - GitLab interface, projects, and SSH setup
Quick SSH Test:
|
|
Expected: Welcome to GitLab, @username!
If you have any problem you need to declare the key on your system. First launch the ssh agent and then add your key with the following commands:
|
|
Git Configuration (Everyone First)
Before starting, verify and configure your Git identity:
|
|
Section A: You as Alice (Project Creator)
A1. Create Your Project
|
|
A2. Create GitLab Project
- Go to GitLab IMT
- Create new project:
hello-world-[your-name] - Set visibility to Private
- Don’t add README (we have local content)
|
|
A3. Add Your Partner as Collaborator
- In GitLab project: Settings → Members
- Add your partner’s GitLab username
- Set role to Developer
- Share project URL with your partner:
https://gitlab.imt-atlantique.fr/[your-username]/hello-world-[your-name]
A4. Wait and Monitor Your Partner’s Contribution
Your partner will clone and contribute. Monitor in GitLab, then pull:
|
|
A5. Create Template for Future Conflict
Add a template that both you and your partner will fill out:
|
|
Notify your partner that the template is ready for them to pull and fill out.
A6. Fill Template (Coordinate with Partner)
Important: Coordinate with your partner to fill the template simultaneously:
|
|
A7. Resolve Conflict (If You Push Second)
|
|
Understanding Merge Conflicts: When Git can’t automatically merge changes, it marks conflicts in your files with special markers:
|
|
Resolving Conflicts - Text Editor Method:
|
|
Resolving Conflicts - VS Code Method:
|
|
Complete the merge:
|
|
🔗 Why Conflicts Happen & How Branches Help:
Conflicts occur when two people modify the same lines in the same file. The template scenario demonstrates this perfectly - both people filled the same blank lines simultaneously.
Branches help minimize conflicts by:
- Isolating features: Each developer works on separate branches
- Reducing overlap: Different features are developed independently
- Controlled integration: Changes are merged through review process
- Parallel development: Multiple features can be developed simultaneously
This is why professional teams use branching strategies - you’ll practice this next!
A8. Understanding Branches & Merge Requests
Why Use Branches?
- Isolation: Develop features without affecting main code
- Collaboration: Multiple people can work on different features simultaneously
- Safety: Main branch stays stable while experimenting
- Review: Code can be reviewed before integration
What Are Merge Requests?
- Code Review: Team members review changes before merging
- Discussion: Collaborate on implementation details
- Quality Control: Ensure code meets standards
- Documentation: Track what changes were made and why
Create Feature Branch (Your Project):
|
|
A9. Create Merge Request on Partner’s Project
Instead of merging on your own project, create a feature for your partner’s project:
|
|
Create Merge Request:
- Go to your partner’s project in GitLab
- Click “Create merge request”
- Source:
feature/add-[your-name]-contribution→ Target:main - Title: “Add [Your Name]’s collaboration feature”
- Description: “This feature adds enhanced collaboration information to the project”
- Assign to your partner for review
Section B: You as Bob (Collaborator)
B1. Clone Your Partner’s Project
Your partner will share their project URL with you:
|
|
B2. Make Your First Contribution
|
|
B3. Fill Template and Participate in Conflict
When your partner notifies you that the template is ready:
|
|
B4. Review and Merge Your Partner’s Feature
When your partner creates a merge request on YOUR project:
- Go to your project in GitLab
- Open the merge request created by your partner
- Review changes in “Changes” tab
- Check the new feature they added
- Add a comment: “Nice feature! Thanks for the contribution 👍”
- Click “Approve”
- Click “Merge” to integrate their feature
- Choose “Delete source branch” for cleanup
B5. Sync After Merge
|
|
Complete Workflow Summary
What each student accomplishes:
As Alice (Project Owner):
- ✅ Create Git repository and GitLab project
- ✅ Manage collaborator permissions
- ✅ Handle merge conflicts as project owner
- ✅ Create feature branches and merge requests
- ✅ Experience project management workflow
As Bob (Collaborator):
- ✅ Clone existing project
- ✅ Contribute to someone else’s codebase
- ✅ Participate in conflict resolution
- ✅ Review and approve merge requests
- ✅ Experience contributor workflow
Collaboration Skills Gained:
- ✅ Basic Git: clone, commit, push, pull
- ✅ Conflict Resolution: merge conflicts handling
- ✅ Code Review: merge request workflow
- ✅ Team Coordination: asynchronous collaboration
Final Validation
Test your understanding:
|
|
Success criteria:
- Both projects have contributions from both people
- You’ve resolved at least one merge conflict
- You’ve created and merged a feature branch
Next Steps
🔗 Deepen your knowledge:
- Pro Git Book - Complete Git reference
- GitLab Flow - Professional branching strategies
- Git Best Practices - Team collaboration patterns
🎉 Ready for real projects! You now have the first collaborative Git skills used in professional development teams.