Git Grep Searching -


i trying compare 2 commits of git project. clone repository postfix folder, use:

git --grep=xxx 

where xxx commit number, retrieve hash , use git checkout retrieved hash.

however, git grep returns details of particular commit.

if example commit had id 24, enough me retrieve commit id 23 in order version of project without fix?

background

i'm not sure ids you're talking about: git commits not have sequental ids , identified sha-1 names hashes calculated on corresponding commit objects.

so might suppose you're talking project embeds externally generated ids. 1 reason might project follows subversion repository default commits created in such repository have subversion url , revision id artifically embedded in messages.

what take out of this

first things first: in general, answer question no. reason git commit might have more 1 parent—if it's merge commit. hence considering commit , merely stepping backwards (see below how that) not possible.

how select parent commit?

the gitrevisions(7) manual page lists 2 forms of selecting 1 of parent commits:

  • <rev>^, e.g. head^, v1.5.1^0

    a suffix ^ revision parameter means first parent of commit object. ^<n> means <n>th parent (i.e. <rev>^ equivalent <rev>^1). special rule, <rev>^0 means commit , used when <rev> object name of tag object refers commit object.

  • <rev>~<n>, e.g. master~3

    a suffix ~<n> revision parameter means commit object <n>th generation ancestor of named commit object, following first parents. i.e. <rev>~3 equivalent <rev>^^^ equivalent <rev>^1^1^1. see below illustration of usage of form.

as can see, git either forces indicate parent explicitly or assume first (also "left") parent (this 1 merge has been made into).

hence, once know sha-1 name of commit, let 2abcde45, can refer first parent using 2abcde45^ or 2abcde45^1 or 2abcde45~1 same this task.


i'd again stress fact git commits not have "ids" in sense seem using, please take time know ids you're dealing with. posting question here on citing commit message of sample commit ok, think.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -