Skip to content

Instantly share code, notes, and snippets.

@mauricioszabo
Created August 31, 2021 17:44
Show Gist options
  • Save mauricioszabo/e6e35ec123fdb76e0b917e79bd350fb5 to your computer and use it in GitHub Desktop.
Save mauricioszabo/e6e35ec123fdb76e0b917e79bd350fb5 to your computer and use it in GitHub Desktop.
Squash and lost history
╰─>$ git checkout -b feature-branch
Switched to a new branch 'feature-branch'
╰─>$ git commit -a -m 'Commit 2'
[feature-branch 1f16b96] Commit 2
1 file changed, 1 insertion(+)
╰─>$ git commit -a -m 'Commit 3'
[feature-branch f7c9f08] Commit 3
1 file changed, 1 insertion(+)
╰─>$ git merge --squash feature-branch
Updating 1efbcd8..f7c9f08
Fast-forward
Squash commit -- not updating HEAD
some-file.txt | 2 ++
1 file changed, 2 insertions(+)
╰─>$ git commit -v
[master b4f8101] Squashed commit of the following:
1 file changed, 2 insertions(+)
╰─>$ git branch -d feature-branch
error: The branch 'feature-branch' is not fully merged.
If you are sure you want to delete it, run 'git branch -D feature-branch'.
╰─>$ git branch -D feature-branch
Deleted branch feature-branch (was f7c9f08).
# No info about the feature-branch:
╰─>$ git log --oneline --graph
* b4f8101 (HEAD -> master) Squashed commit of the following:
* 1efbcd8 Commit 1
# Dangling commit:
╰─>$ git fsck --lost-found
Checking object directories: 100% (256/256), done.
Checking objects: 100% (10/10), done.
dangling commit f7c9f0860e0de7ba0e1299d8c71a8f67c3dfdf52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment