I am using Git for my project and trying to follow best practice:
- I work on a topic branch
- When ready, I merge the topic branch into my dev branch using
git merge --squash
. This keeps my dev branch clean. - Whenever the dev branch is stable and the team decides it's time for a release, we merge the dev branch into the master branch, without using squash, and tag that commit as a version release.
This should keep our history, and using gitk, we can see where all of the commits come in. However, I want to be able to see only the commits applied to the master branch. I have tried:
git log master
git show-branch
None of these show just the history of the master branch. Is there a way to easily do this?
If I'm understanding you correctly, you want to see the merges back into master, but not the history of those merges. I believe that:
will give you what you want.
UPDATE: Adding --first-parent should fix this from the sounds of it.
Since Git does not store information about which branch is nascent from which other, there is no automatic way to guess which branch you could possibly want to be shown.
In that regard,
--first-parent
will not ultimately help, especially since it is easy to have more than one master, for example. Consider:(Feel free to take a random project and do this exercise.) Graph it. So you cannot meaningfully graph "just one branch", even if the commits were tagged with the name of the branch they were made on (because both are master).
Unfortunately, Git does not store branch information for a commit, and commits do not belong to a branch. Branches in Git are just "moving tags" in a course of commits and NOT a sequence of commits as one would expect.
So basically you cannot show commits that belong to a branch since there is no such concept in Git.