Git Feature Branch Workflow

Git is the most widely used versioning control system for tracking source code files. It contains multiple branches that allow users to work on different code versions simultaneously. Additionally, feature branching also plays a significant role. It permit multiple teams of developers to participate in a master branch within a central code base.

This post will demonstrate the complete workflow of the Git feature branch.

What is the Git Feature Branch?

When programmers write code while working on Git, they tend to do so on Git branches. It becomes challenging to add, change, or remove code when several developers are working on the same branch without their efforts overlapping or overwriting one another’s modifications. A Git “feature” branch is used when a developer wants to create a copy (1:1) of the “master” branch from which they can make changes. The easiest way to visualize it is as a tree with a trunk that serves as the master branch and branches that are copies of other codebases.

Git Feature Branch Workflow

To combine all the modifications from a local branch into a remote “feature” branch, check out the provided instruction:

  • Navigate to the Git root directory.
  • List all Git local branches.
  • Run the “git checkout -b” command to create a feature branch.
  • Verify the newly created feature branch.
  • Execute the “echo” command to create and edit the file.
  • Track the newly generated file into the staging environment with the help of the “git add” command.
  • Run the “git commit -am” command to commit changes.
  • Lastly, push the “feature” branch to GitHub and verify it.

Step 1: Redirect the Git Repository

First, redirect the Git root directory using the “cd” command and navigate to it:

cd "C:\Users\user\Git\test repo"


Step 2: List Git Branches

Run the “git branch” command to view/check the existing local branch:

git branch


Step 3: Design a Feature Branch

Run the “git checkout” command along with the “-b” option for making and navigating to the new branch:

git checkout -b feature2


It can be observed that we have successfully created and switched to the “feature” branch:

Step 4: View Current Git Branch

Run the below-stated command to view the current working branch:

git branch


According to the below-given output, the asterisk “*” beside the “feature2” indicates that it is the current working branch:

Step 5: Create and Edit the File

Utilize the “echo” command to make and edit the file simultaneously:

echo "my first file" >> file8.txt


Step 6: Track File to Staging Environment

To track the newly created file from the working area to the staging index, run the provided command:

git add file8.txt


Step 7: Commit Changes

Next, save the changes through committing, execute the “git commit” command along with the “-am” option for adding all changes tracked as well as untracked:

git commit -am "feature module"


Step 8: Push Feature Branch to GitHub

To push the feature branch to GitHub, the “git push” command can be used with the remote and branch name:

git push origin feature2


After that, navigate to the GitHub remote repository where changes have been pushed. And verify through the “features2 has …..” message:

That’s all! We have explained the Git feature branch workflow.


To follow the Git feature branch workflow, initially, navigate to the Git root directory. Next, list all existing local branches. Run the “git checkout -b” command to create and switch branches simultaneously. Then, use the “echo” command to create and update the file. Track changes by utilizing the “git add” command and save them to the Git repository by running the “git commit -am” command. Lastly, push the local changes to the remote server. This post illustrated the complete workflow of the Git feature branch.

About the author

Hafsa Javed