When to rebase.

Git rebase is a powerful tool, but there’s a right and a wrong time to use it.

So the main rule of rebasing is to never rebase a branch once other people have seen it.

Only rebase your code before the first code review. It’s good to rebase your code before sharing it with others because it will flatten out all the various commits into something that’s a lot easier to examine.

Once others start reviewing your code, you shouldn’t rebase. Other people may be writing new commits on your code, and if you rebase it, you’ll be changing the history and their commits won’t work with your changes.

So follow this simple rule and you’ll avoid trouble.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: