Show commits on detached head

If I do these steps:

  1. git checkout mytag # I am on detached head now.
  2. git commit
  3. git commit

Which git command can be used to see the changes between mytag and the current state?

This command should not use "mytag", since it is not available any more.


try git merge-base

git log `git merge-base HEAD master`..HEAD

git merge-base will give you the common ancestor between two branches. Then git log A..B will give you the commit history from A to B

instead of master you can use the branch where mytag started from.

You can use

git show

to view the changes introduced by the previous commit (the one where HEAD is currently pointing). You can also use git show <COMMIT> to view the changes introduced by any single commit you specify. (Details in the git show manpage.)

If you want to view the difference between two points, you can use

git diff <FROM> <TO>

where both <FROM> and <TO> refer to any commits (or references to commits, etc). (Details in the git diff manpage.)

In your specific case, when you want to view the difference between the current commit and two commits ago, you can use

git diff HEAD~2 HEAD

where HEAD~2 the 2nd-generation ancestor commit of HEAD (=where you currently are). This avoids using the refname of mytag, as you requested.

Details about the <ref>~<n> notation can be found in the gitrevisions manpage.

Need Your Help

Add SQL Server Instances to Central Management Server Groups with Powershell

sql sql-server powershell content-management-system smo

I am trying to create a script to automatically iterate through a text file of all our SQL Server instances and add each on if it doesn't already exist to the CMS. I want to try doing this through ...

Nokogiri Element Removal Using Regex in Ruby

ruby regex nokogiri

This seems like the hardest problem I have had yet, but maybe I am making it harder than it needs to be. I need to remove an unknown number of nested elements that may or may not be at the beginn...