Timeline for How to squash all git commits into one?
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 10, 2023 at 16:09 | comment | added | victorlin |
You can replace <root> with $(git log --reverse --pretty=format:"%h" | head -n 1) .
|
|
Apr 4, 2023 at 15:38 | comment | added | user5359531 | the orphan branch solution does not remove old reflog messages reflecting actions (and user names and email addresses) associated with the old removed branch's commits. You can delete these reflog entries locally but if the commits have already been pushed to a remote repo on GitHub they will remain in the reflog when someone clones it again. So, using an orphan branch does not completely erase the history of the repo. | |
Feb 28, 2023 at 7:51 | comment | added | Raleigh L. | Can't believe I had to scroll down this far to find this, the orphaned branches solution worked perfectly for me and I haven't found any downsides of this approach. This should've been the accepted answer. | |
Feb 9, 2023 at 8:25 | comment | added | SOFe | @AndrewMackie that's pretty much what "squash all git commits into one" means by definition though. Applies to every other answer as well if the original branch is eventually reset to this commit. | |
Mar 23, 2022 at 20:04 | comment | added | Staghouse | Don't know how, or why. But followed Solution #1 and all my commits were erased. Luckily i made a backup branch. | |
Feb 8, 2022 at 19:36 | comment | added | phatmann | The soft reset solution is perfect for me. Easy and comprehensible! | |
May 13, 2020 at 15:54 | comment | added | FernAndr | Alternative solution #1 also avoids the merge conflicts that can occur when squashing commits | |
Mar 29, 2019 at 0:54 | comment | added | Andrew Mackie | Don't do an orphan branch on code (i.e. don't do alternative solution #1 above) if you're about to push to an open Github pull request!!! Github will close your PR because the current head isn't a descendant of the stored head sha. | |
Mar 28, 2018 at 16:38 | comment | added | NecipAllef |
should not forget git push --force
|
|
Sep 9, 2016 at 11:01 | comment | added | Eddy Verbruggen |
Alternative solution #1 FTW. Just to add, if you want to push your changes to the remote, do git push origin master --force .
|
|
May 9, 2016 at 15:51 | comment | added | Thomas | Alternative solution #1: orphan branches - rocks! | |
Aug 3, 2014 at 2:13 | history | edited | user456814 | CC BY-SA 3.0 |
Updated documentation links.
|
Jul 23, 2014 at 16:23 | history | edited | user456814 | CC BY-SA 3.0 |
Updated with another alternative solution.
|
Jun 11, 2014 at 3:24 | history | answered | user456814 | CC BY-SA 3.0 |