Working as a Team in Software Development Using Git and Git Flow

Faza Aryoga
Electronic Logbook
Published in
4 min readMar 21, 2021
Photo by Pankaj Patel on Unsplash

Have you ever wrote a document with multiple people where everyone is working on same file with everyone having different ideas and may work on the same parts of document and eventually everything becomes messy and hard to keep track of everyone’s work? well the same kind of things happen to in software development. Programmers do, however, a to mitigate this using Git. This article is written with knowledge gained from my own experiences to inform you the use of Git and Git Flow.

What is Git?

Git is a version control system made by Linus Torvalds in 2005. It allows for tracking change in files, usually used in coordinating programmers who are working collaboratively. Git is free, quick, and allows for non-linear workflows.

How Do You Use Git?

First, you will need to download and install Git, you can download git here.

Initialize a Git Repository

Using Git revolves around repositories, now with Git downloaded and installed we can now use Git to make any folder a Git repository. All you need now is open a command prompt/console, navigate to folder you wish to make repository and then type in the command git init and run it, voila! now you have a working local Git repository. You can use the command git status to display information of your repository such as file changes, additions, and deletions that happens in that repository. Now, you need to create a remote Git repository if you want to collaborate with others, you can use vendors such GitHub and GitLab and simply add a remote reference in your local repository by using the command git remote add [remote name] [repository link].

Commits and Git Push and Git Pull

Now that you have a local and remote repository, you can now send the contents of your local repository to the remote one but first you add the changes you made to the repository by using the command git add [changed filename] or git add . to add all the changes to the commit snapshot. Once you’ve added all changes you can then use the command git commit [commit message] to commit a snapshot which can be “pushed” to the remote repository using the command git push [remote branch name]. If you want to have the contents of the remote repository you use git pull [remote branch name]. If you want to push commits but someone else have already pushed a more recent commits you will need to pull the commits first, resolve any conflicts, and then push your newer commit.

Git Branch and Git Checkout

The way Git allow developers to work together is by using branches, when you first initialize a Git repository you are automatically on the master branch. You can use the command git branch [branch name] to create a new branch and subsequently use the command git checkout [branch name] to change branches or you can use the command git checkout -b [branch name] to create a new branch and change to that branch in one command. Any changes made to the repository will only apply to branch you are currently in.

Git Merge

When you want to combine two branches together you can use the command git merge. This is very useful for when, for example you want to integrate a new feature from a feature branch to the master branch. To create a git merge you must first move to the branch where you want the merging to happen so for example if you want to merge a feature to the master branch you first checkout to the master branch and then run the command git merge [The branch you want to merge to the branch you are on now].

Git Flow

Git Flow is a software development workflow using Git that is suitable with continuous development. It features two main branches during the master/production branch and the development/staging branch.

How It Works

Example branch of a Git Flow

Master branch and Staging Branch

Instead of using only one master branch, this workflow uses two main branches that serves to record the development of the product. The master or production branch is reserved for the finished publishable product available to the customers often commits to this branch include the version number while the staging or development branch is the one used to integrate features and is the one mainly worked on. Needless to say the staging branch branches off from the main branch.

Feature Branches

In this workflow, every feature or a user story item should have its own branch which stems from the staging branch. When the feature is completed, the feature branch will be integrated back to staging branch.

Hotfix and Coldfix branches

Hotfix and coldfix branches are only used to swiftly patch issues on the master and staging branch respectively. When issues in the hotfix branch are resolved, it will be merged with the master and staging branch while the coldfix branch will only be merged back with the staging branch.

--

--