Today I learned `git diff feature..main`
Today I learned how to diff between two branches.
git diff feature..main
Sometimes we get a little git add . && git commit -m "WIP" happy and mistakenly commit something that we just can’t figure out. This is a good way to figure out what the heck has changed on the current branch compared to any other branch.
Example # [1]
Let’s create a new directory, initialize git [2] and toss some content into a readme.
mkdir git-diff
git init
echo "hello there" > readme.md
git add . && git commit -m "hello there"
cat readme.md
After all of that, we have a git repository on our local machine with a single file readme.md that contains the following.
hello there
Create a branch and ✍ edit # [3]
Let’s checkout a new branch called Waylon and change the word there to Waylon in our readme.md file, then diff it.
git checkout -b Waylon
echo "hello Waylon" > readme.md
git add . && git commit -m "hello Waylon"
git diff
- hello there
+ hello waylon
At this point we have one commit. Things are real...