17

I've been learning Git recently and came to know rebasing is good in some cases to avoid merge commits and keep history clean.

Also I read that extra care should be taken while using git rebase.

Can someone please describe some cases in answers below, in which cases using git rebase is a bad choice.

nwinkler
  • 49,757
  • 20
  • 150
  • 164
Foolish
  • 3,582
  • 28
  • 41

1 Answers1

7

Case 1: We should not do Rebase on branch that is public, i.e. if you are not alone working on that branch and branch exists locally as well as remotely rebasing is not a good choice on such branches and it can cause bubble commits.

Case 2: We should not do Rebase on pushed commits, i.e. If you are working on branch br1 and you already have pushed some commits to this branch on remote (or origin) you should not do rebase on this branch br1. Check this Question for reference: Rebasing and what does one mean by rebasing pushed commits

Leomord
  • 171
  • 11
Foolish
  • 3,582
  • 28
  • 41
  • 1
    Case 1 is a valid point and agreeable but case 2 is at some scenarios to have a clean commit history you'd want to rewrite the history unless the branch is not diverged at any point. So my point here is , one can still rebase the tip and use --force-with-lease option while pushing which cautiously rewrites the remote history – Vijaykrish93 Jul 09 '19 at 16:45