Skip to content

Xiao-dong-LIU/GitTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A small collaboration project to practice git

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.

1. Fork the project

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.

2. Clone the repository

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.

3. Commit and push

In this part, Dev.B does the same thing as Dev.A, but in Step 2

  1. Dev.A delete "/" and "/" in Step 1 in file main.cpp, check the change with
git statut
  1. Dev.A stage the modifications (check gitk)
git add main.cpp
  1. Dev.A commit this modifications
git commit -m "uncomment Step 1"

check gitk

  1. 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 the git push

  1. Try to get the same output for gitk when finished.

4. Branch and merge

In this part, Dev.B does the same thing as Dev.A, but in Step 4

  1. Dev.A creates a branch "uncommentStep3" ("uncommentStep4" for Dev.B)
  2. Checkout to the new branch, and check it to make sure
git branch
  1. Dev.A deletes comments of Step 3
  2. Commit the modifications and merge it to main branch
git checkout main
git merge uncommentStep3
  1. push it to remote and try to get the same workflow one gitk

5. Manage conflicts

  1. Dev.B creates a new branch "PCG".
  2. Dev.B uncomments Step 6.1 and delete Step 6.2.
  3. Dev.B commits this modification and merge it main.
  4. Dev.B publishes it to remote.
  5. Dev.A creates a new branch "CG".
  6. Dev.A uncomments Step 6.2 and delete Step 6.1.
  7. Dev.A commits this modification.
  8. Dev.A checkout to main.
  9. Dev.A does a git pull to update his local main branch
  10. Dev.A merge branch "CG" to main.
  11. 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.

6. Manage remote

  1. Dev.B creates an annotated tag named "V1.0"
git tag -a v1.0 -m "version 1.0"
  1. Dev.B publishes this tag to remote
git push origin v1.0 
  1. Check tag in remote
  2. Dev.A fetches this tag to his local and check it on gitk
  3. Dev.A creates a private empty project in Koda.
  4. Dev.A creates also a private empty project in Koda.
  5. Both publish their project to Koda.

Checkout from a specific commit

  1. 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)
  1. Both uncomment "Step 7", and commit this modifications.
git commit -a -m "uncomment Step 7"
  1. 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"
  1. Dev.B adds the following line before return 0 in "main.cpp"
std::cout<<"Problem solved!"<<endl;
git commit -a -m "add end line"
  1. Both delete the line /*******Step 1 ********/
  2. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages