Git Working in groups - EPFL-MICRO-315/TPs-Wiki GitHub Wiki
- To be the most effective, it's essential to use correctly the tool Git
- In fact, Git is a tool great for both versioning and working in teams
- Git is such a versatile tool that there is never only one way to do it
- There are however things you should not do and things we recommend you do
- do not create more branches than the set
- TPIntro_Exercise
- TP1_Exercise
- TP1_Solution
- TP2_Exercise
- TP2_Solution
- ...
- Because you are likely to work on only one computer during the TPs, we recommand you and your teammate to work in the same branch (e.g: TP1_Exercise)
- If both of you have edited files in the same time on your own computer, then you might run into conflicts
- To solve those conflicts, simply merge the two versions
In a purely hypothetical context, suppose that:
- the student1 modifies the file main.c and then push the changes to the repository
- the student2 modifies the file main.c and then try to push the changes to the repository BUT he forgot to pull the changes student1 made
- student2's push trial will not succeed because of conflicts, in fact the file main.c have 2 conflicting histories
- 💡 there are mutiple ways of solving this conflict, for the sake of simplicity no fancy operations like rebase will be used, instead we propose you a method using 2 operations:
fetchandmerge - the conflict resolution will be naturally resolved from student2's computer
- fetch the student1's modification
- merge the student1's modification with the current branch
- you can click
Open merge editorto be in a more user friendly UI - in the areas
1and2you can select which changes, line by line that will appear in the merged branch - it is also possible to make further changes in the area
3 - When you think the merge is complete, click on
Accept Mergeand then commit it
Supposing your group has dispatched the work among student1 and student2 by tasks:
- It makes sense in this case to create a branch for student1 and another for student2 respectively named
student1andstudent2 - There would still be a main branch named
main - Once student1 is happy with his version, he merge his modifications with the branch
main:output console:git checkout main git merge student1