Once you have published a repository from which others might make a clone, you should consider it static and refrain from rewriting the history of any branch. Although this is not an absolute guideline, avoiding “rewinds” and alteration of published history simplifies the life of anyone who clones your repository.
Let’s say you publish a repository that has a branch with
D. Anyone who clones your
repository gets those commits. Suppose Alice clones your repository
and heads off to do some development based on your branch.
In the meantime, you decide, for whatever reason, to fix
something in commit
B remain the same, but starting with commit
C, the branch’s notion of commit history changes.
You could slightly alter
C or make some totally new
X. In either case, republishing the
repository leaves the commits
B as they were but will now offer, say,
X and then
Alice’s work is now greatly affected. Alice cannot send you
patches, make a pull request, or push her changes to your repository
because her development is based on commit
Patches won’t apply because they’re based on commit
D. Suppose Alice issues a pull request and you attempt to pull her changes; you may be able to fetch them into your repository (depending on your tracking branches for Alice’s remote repository), but the merges will almost certainly have conflicts. The failure of this push is due to a non-fast-forward ...