Tutorial by Examples

$ git show dae86e1950b1277e545cee180551750029cfe735 $ git show dae86e19 You can specify revision (or in truth any object: tag, tree i.e. directory contents, blob i.e. file contents) using SHA-1 object name, either full 40-byte hexadecimal string, or a substring that is unique to the repository. ...
$ git log master # specify branch $ git show v1.0 # specify tag $ git show HEAD # specify current branch $ git show origin # specify default remote-tracking branch for remote 'origin' You can specify revision using a symbolic ref name, which includes branches (for example 'master'...
$ git show # equivalent to 'git show HEAD' 'HEAD' names the commit on which you based the changes in the working tree, and is usually the symbolic name for the current branch. Many (but not all) commands that take revision parameter defaults to 'HEAD' if it is missing.
$ git show @{1} # uses reflog for current branch $ git show master@{1} # uses reflog for branch 'master' $ git show HEAD@{1} # uses 'HEAD' reflog A ref, usually a branch or HEAD, followed by the suffix @ with an ordinal specification enclosed in a brace pair (e.g. {1}, {1...
$ git show master@{yesterday} $ git show HEAD@{5 minutes ago} # or HEAD@{5.minutes.ago} A ref followed by the suffix @ with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) specifies the value of the ref at ...
$ git log @{upstream}.. # what was done locally and not yet published, current branch $ git show master@{upstream} # show upstream of branch 'master' The suffix @{upstream} appended to a branchname (short form <branchname>@{u}) refers to the branch that the branch specified by branc...
$ git reset --hard HEAD^ # discard last commit $ git rebase --interactive HEAD~5 # rebase last 4 commits A suffix ^ to a revision parameter means the first parent of that commit object. ^<n> means the <n>-th parent (i.e. <rev>^ is equivalent to <rev>^1). A...
In some cases the behavior of a command depends on whether it is given branch name, tag name, or an arbitrary revision. You can use "de-referencing" syntax if you need the latter. A suffix ^ followed by an object type name (tag, commit, tree, blob) enclosed in brace pair (for example v0.9...
$ git show HEAD^{/fix nasty bug} # find starting from HEAD $ git show ':/fix nasty bug' # find starting from any branch A colon (':'), followed by a slash ('/'), followed by a text, names a commit whose commit message matches the specified regular expression. This name returns the younge...

Page 1 of 1