This is simple pcg solver in c++ generated by chatgpt and modified after.
The objective of this TP is not to understand c++ code, but to practice git.
In fact, in the program, lots of sections are commented in main.cpp. What you need to do is to remove "/" before the section and "/" after each section to let the program output information.
As there are several files, you can work in groupe (2 personnes) to achieve the efficiency.
You do not have write permission on this project, you will hence need to fork it. Of course, since Dev.A and Dev.B will be collaborating to the same project, only one of them should create the fork for the group.
Dev.B: Fork the project by clicking on the fork button in the upper right corner of the project page.
Now Dev.B has his own copy of the project. In order to give Dev.A write permissions to the project, Dev.B needs to add Dev.A to the project’s list of collaborators: Settings -> Collaborators.
Both Dev.A and Dev.B clone it and then go to the local repository
cd GitTP
Both open gitk to visualize the workflow
gitk --all &
gitk should be updated after each git command to check the changes.
In this part, Dev.B does the same thing as Dev.A, but in Step 2
- Dev.A delete "/" and "/" in Step 1 in file main.cpp, check the change with
git statut
- Dev.A stage the modifications (check gitk)
git add main.cpp
- Dev.A commit this modifications
git commit -m "uncomment Step 1"
check gitk
- Dev.A push this commit
git push
One of the teammate will find that it is not possible to push the modifications. Try to figure it out.
Tips: The teammate push after the first need to do
git pull
before thegit push
- Try to get the same output for gitk when finished.
In this part, Dev.B does the same thing as Dev.A, but in Step 4
- Dev.A creates a branch "uncommentStep3" ("uncommentStep4" for Dev.B)
- Checkout to the new branch, and check it to make sure
git branch
- Dev.A deletes comments of Step 3
- Commit the modifications and merge it to main branch
git checkout main
git merge uncommentStep3
- push it to remote and try to get the same workflow one gitk
- Dev.B creates a new branch "PCG".
- Dev.B uncomments Step 6.1 and delete Step 6.2.
- Dev.B commits this modification and merge it main.
- Dev.B publishes it to remote.
- Dev.A creates a new branch "CG".
- Dev.A uncomments Step 6.2 and delete Step 6.1.
- Dev.A commits this modification.
- Dev.A checkout to main.
- Dev.A does a git pull to update his local main branch
- Dev.A merge branch "CG" to main.
- Dev.A publishes it to remote.
Here Dev.A has to handle the conflicts when merge "CG" to main. You can choose either PCG or CG.
- Dev.B creates an annotated tag named "V1.0"
git tag -a v1.0 -m "version 1.0"
- Dev.B publishes this tag to remote
git push origin v1.0
- Check tag in remote
- Dev.A fetches this tag to his local and check it on gitk
- Dev.A creates a private empty project in Koda.
- Dev.A creates also a private empty project in Koda.
- Both publish their project to Koda.
- Both do a checkout from your first commit obtained in section "Commit and push" and give a name to this branch "addContent"
git checkout -b addContent Hash (Hash: commit ID)
- Both uncomment "Step 7", and commit this modifications.
git commit -a -m "uncomment Step 7"
- Dev.A adds the following line before "Step 1" in "main.cpp" and commit it
std::cout<<"This is a iterative solvor to solve Ax=b"<<endl;
git commit -a -m "add solvor description"
- Dev.B adds the following line before
return 0
in "main.cpp"
std::cout<<"Problem solved!"<<endl;
git commit -a -m "add end line"
- Both delete the line
/*******Step 1 ********/
- Both try to merge the fastest commit to main.
git checkout main
git cherry-pick hash
Both do a git pull
than git push
.
You may need
git stash
to switch to branch main