I am learning git.
In this book I read that rebase is not safe when I pushed commits into public repository. It is clear. But what if I didn't pushed commit-X, but created local branches After commit-X are made and want to change this commit?
I tried to change name of the old commit in master branch using git rebase -i HEAD~3
and see that hash has changed. Meanwhile in my work branch same commit didn't changе and have different hash for this commit in master and work branch now.
The created issue was fixed by simple git rebase master
. But I wonder whether I was just lucky and can't I have a problem in such cases?
What is the correct way to rewrite commit history if I have several branches, which depend on commits being rewritten? Is rebasing always safe in such a cases? If not, then when exactly it is not safe? What kind of changes I must avoid here to be safe?