It is often said that, you should not rebase commits that you have already pushed. What could be meaning of that?
The ProGit book has a good explanation.
The specific answer to your question can be found in the section titled "The Perils of Rebasing". A quote from that section:
When you rebase stuff, you’re abandoning existing commits and creating new ones that are similar but different. If you push commits somewhere and others pull them down and base work on them, and then you rewrite those commits with git rebase and push them up again, your collaborators will have to re-merge their work and things will get messy when you try to pull their work back into yours.
Update:
Based on your comment below, it sounds like your are having difficulty with your Git workflow. Here are some references that may help:
- The
gitworkflows
man page: See "Merging Upwards" and "Topic Branches" - ProGit: See "Private Managed Team"
- Jarrod Spillers blog: See "git merge vs git rebase: Avoiding Rebase Hell"
A rebase alters the history of your repository. If you push commits out to the world, i.e., make them available to others, and then you change your view of the commit history, it becomes difficult to work with anyone who has your old history.
Rebase considered harmful is a good overview, I think.
Rebasing rewrites history. If nobody knows about that history, then that is perfectly fine. If, however, that history is publicly known, then rewriting history in Git works just the way it does in the real world: you need a conspiracy.
Conspiracies are really hard keep together, so you better avoid rebasing public branches in the first place.
Note that there are examples of successful conspiracies: the pu
branch of Junio C. Hamano's git repository (the official repository of the Git SCM) is rebased frequently. The way that this works is that pretty much everybody who uses pu
is also subscribed to the Git developer mailinglist, and the fact that the pu
branch is rebased is widely publicized on the mailinglist and the Git website.