Want to know how to work on a group project using Git and GitHub?

How to start a new project or start working on a group project with a team

Want to know how to work on a group project using Git and GitHub?

I am currently enrolled in a virtual internship where I have come to work with so many different people on project we are being assigned and I came to a realization that so many people still find it hard to work with git and github. This spark or inspired me to come up with this article to lay down a step-by-step guide on how to work effectively in a group without having to face the problem of having conflicts, wiping other people's code and also to avoid crashing the server.

Fork the project repo


This above is a screenshot of a sample repository, lets say this is the group project repository on github. The first thing you want to do is to fork the repo to create your own personal version of the repository just as shown below

fork.JPG after forking the repo, it will create that same version of repo on your personal account which is what you will be working on throughout the project. Your personal repo should look just like that of the picture below.


Cloning the project to your local system


From the page of your personal repo, there is a green button with the text of code on it, click on it and a drop down would appear which you will copy the address by just clicking on where the blue arrow is pointing.

Steps for cloning a repo

  1. Open your command line or terminal
  2. Go to your desired location of where you want the project to reside on your local machine(eg Desktop)
  3. Write the following command below
git clone url (https://github.com/Ibrahim-Isah/simpson-task.git)

the url is the text you copied from the github repo where you will paste it just like i did mine in the bracket

  1. After cloning the project and receiving the success response, go ahead and open the project on your desired IDE

Working on the project

  1. To start working the just newly cloned project, it is advice to create and work with branch as this is a group project and you dont want to cause your main repo to be ahead of the teams general repo. Creating a new branch is fairly easy and can be done using the following command
git checkout -b feature

this will create a new branch feature and immediately you will be switch to start working on the feature branch.

  1. Write your code and when you are done follow the following commands below to commit it into the feature branch
git add .
git status
git commit -m "Your commit message"
  1. After following the commands above, you want to push the code to your personal github account. Pushing to github can be done by pressing in this command. The first one is done when the branch does not initially exist on github already while the second is used when a branch with the name exist on github already
git push --set-upstream origin feature
git push origin feature

Pushing your work to the team repo


Going back to your github and clicking on master or main, you will see a drop down for where to select on which branch(feature) to view.

pull.JPG Make a pull request by clicking on contribute or using the one highlighted in yellow background. Afterward, you will be taken to another page write a title and description of the commit. Always make your description to define what you solve to make assessment easy for other team members. Click on create pull request and your pull request will be created and be ready for merging just as the last picture depicts.



Conclusion, whenever you encounter a conflict on making a pull request, you can easily solve it by using a new tool github has launched which can be seen where the conflict was reported. you can always ask for guide if you have any issues you dont understand. Thank you for reading my first article