Has my branch been squash-merged into main? | Kaushik's Blog

submited by
Style Pass
2024-06-07 12:30:04

I have a large number of local development branches, several of which had already been merged into main. If the branches were fast-forward merged, things are usually fine. You switch to the main branch and run git branch -d <branch-name>, which will succeed if all the commits on branch-name are also present in main.

If the branch was squashed during merge though, things get interesting. git branch -d <branch-name> fails because git can't verify that all the changes in the branch are also present in main - the commit history is different.

git rev-parse is a complicated command; it does a seemingly infinite number of things. The man page is distressingly long. But one common use is to get the commit SHA1 of a branch/tag, potentially to feed a downstream command that only takes SHA1 values.

A tree object represents the state of the repository at a particular commit - all its files, metadata, subdirectories, etc. The tree object is different from the commit SHA. When a commit is made, a new tree object is created. The commit SHA encodes the difference between the previous tree object and the current tree object.

Leave a Comment