Git: What formats are supported by @ {}?

I am reading git-book . It says to show what is causing your HEAD to point 2 months ago, use git show HEAD@{2.months.ago}

.

Some other useful things you can do with @{}

  • To see where your branch pointed my-branch

    yesterday, dogit show my-branch@{yesterday}

  • To see the nth value of the previous HEAD of your repository use git show HEAD@{n}

From the top it appears that there are various formats supported @{}

that are not limited to the above.

  • What formats are supported @{}

    in git

    ?
  • The above example shows 2 months ago, let's say I want to see for 2 years 4 months 3 days 4 minutes ago or something. Is there any format for such a thing?
+3


source to share


1 answer


What formats are supported by @ {} in git?

It can also be used with

# as you figures out git log
git log
git diff 
git stash stash
git reflog
git merge

      

And there are many more commands that use HEAD references and / or commit.
The concept is to use this shorthand instead of using SHA-1

For example:

Reducing flow

When you have a tracking branch installed, you can refer to its upstream branch with a shortcut @{upstream}

or @{u}

.
So if you are on the master branch and its origin / master is tracking you can say something like git merge @{u}

instead git merge origin/master

if you like.




The example above, shown 2 months ago, let's say I want to see for 2 years 4 months 3 days 4 minutes ago or something. Is there any format for such a thing?

There is no such format for such a strict date. you can use weeks, days, etc. not a difficult combination. if you want to do this you have to write a script to do this

git log maintains --relative-date

--relative-date

/--date=relative


Show date in relative format (eg "2 weeks ago") instead of using full date format.

Additional Information:

https://git-scm.com/docs/git-log#git-log---dateltformatgt

+2


source







All Articles