Let’s use Git(Version Control) to suit each occasion.😉 (part-1)

Danushka Malinga
3 min readFeb 26, 2022

Hi, In this blog I am going to help you work through Git. Which is the system for managing your source code as a programmer. So we are going look in to this topic in two ways.

So simply, How to use Git as an Individual and how to use Git when working with a Team.

In this part 1, I am going to explain how to use Git in a team.

Everywhere in the internet we find what is Git and why we need Git like everything about this version control.

But when we first learn about Git we will subjected to various entanglements. We all learn something to do some specific task. Like we learn Git to do something. But we face various difficulties as we go to learn about Git and put into action. This is because we can use Git for a single task as an individual and apply to a group action as a group.

How to use Git in a team.

I think the person reading this knows what is Git. Here I am going to suggest you a basic workflow that use by many teams.

This is how the workflow works

* Create a new branch to work on a feature or bug.

  • Do not commit a change directly to master. The below command will create a new branch and switch to it
git checkout -b name-you-want-for-branch

* Work on that branch, making several commits.

  • To stage all changes
git add .
  • To check the changes made were added
git status
  • To commit changes
git commit -m "commit-message" 

* Get latest version as always.

  • This will minimize conflicts down the line. You need to pull the latest changes in master.(In this scenario the stable source code is in master)
git pull origin master

* Push local branch to remote repository

  • After done with the changes we can push our local branch to remote. Make sure to get the latest version again.
git push -u origin your-branch-name

* Create a pull request

  • Move in to GitHub and select the repository and in there you can see the below interface.
  • Click compare & pull request
  • Click create pull request by adding meaningful comment

* Do the code review and merge the feature branch to master.

  • This thing usually do by the person who IN charge for the code review.

And that is all for part 1.

Thanks

--

--