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?
Git rebase Rebasing is the process of taking all the changes that were committed on one branch and applying them to a new branch. Run git rebase and add in the -i option to rewrite, replace, delete, and merge individual commits in the history. You can also: Rewrite a past commit message.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history.
(T/F) Git revert is a dangerous command that alters the repository's history.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With