I keep reading about the dangers of squashing/rebasing/amending commits that are already shared with your team members. If the team is asking for this change, how do we do it?
Does everyone stop committing files and just have one person rewrite history, push to GitHub, and then let everyone pull + resume working?
Best Answer
Basically we can rewrite git history any time as long as the git repository is not shared.
If you want to rewrite a shared branch (master for instance), you should rewrite it in local. Once you're done, you should cherry-pick the new commits and stop all activities on this branch from all collaborators. Then you push -f origin main
(don't forget to unprotect it if protected)
At this point you're done. BUT everybody else needs to get that branch without loosing current unpushed work. This can be done if everyone cherry-pick local non-shared commits from the branches created from the old master to the branches created from the new master.