Git 

Introduction

In this post we will discuss how to rebase feature with master branch in Git repository. We have seen post on Git tutorial using command line tool. We will also tell you here using command line tool how to rebase feature branch with master branch in Git repository.

In Git, the rebase command integrates changes from one branch into another. It is an alternative to the merge command. But there is a difference between rebase and merge command.

Rebase is generally performed when you need straight, linear or clean history of commits.

When you need to use merge?

  • When you have pushed the branch or others team members are working on it too.
  • You do not need the full history of activities, i.e., commits.

When you need to use rebase?

  • When you have not pushed the branch or no one else is working on it.
  • You want the full history of activities, i.e., commits.
  • You want to avoid all the auto-generated merged commit messages.

Performing Git Rebase

Here are in general few steps which will tell you how to perform rebase using command line tool.

  1. Navigate to the root directory of your project where you want to perform rebase.
  2. Execute command git fetch && git rebase origin/master. In this case, you have navigated to the feature branch using command line tool to execute the command.
  3. If conflict occurs, manually resolve them in each file.
  4. Execute command git rebase --continue to continue rebase. You will also get the similar message on console window to perform the same thing.
  5. If conflicts occur again follow steps 3 & 4, otherwise execute git pull from your feature branch if there is any difference.
  6. Commit the code to repository for feature branch.

Thanks for reading.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *