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.