I'm currently learning about the power of git rebase, but I'm also aware of its potential dangers.
Now, after reading a lot of online resources, I'm really confused:
First of all, I read the advice "never use rebase on a public branch", yet at the same time, I read another piece of advice saying "git pull --rebase" (git pull --rebase on public branches) is not dangerous. Isn't that contradicting?
Now, I'm trying to think of 2 possible scenarios here:
1. Developing on a private feature branch as a solo developer
In this case, I can always do "git rebase master" to get new changes from main branch without changing/breaking the commit history. Concerning "git pull --rebase", I think it isn't necessary for this use case.
2. Developing on a public feature branch with other developers
This one seems tricky to me. As far as I can tell "git pull --rebase" shouldn't be a problem, because only the hash codes of my local commits will be changed.
However, what about doing "git rebase master" on a public feature branch? Is this dangerous for my colleagues/the public commit history?
Finally, as a last security mechanism, I'm trying to think of rules that help me to be on the safe side with rebasing:
Rule 1: As long as I don't have to "force push", everything is fine with my rebase and I didn't break the commit history.
Rule 2: As long as I didn't change the hash codes of public (already pushed) commits, everything is fine with my rebase and I didn't break the commit history.
I'm not so sure about rule 1, but I think rule 2 is correct (the question here is how to check that rule).