Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't-repeat-yourself git revision range syntax?

Tags:

git

Suppose S is the SHA of a git commit.

How can we express the range S^..S without the annoyance of repeating S?

In other words, "give me the one-commit range ending in commit S".

(And is there way which generalizes to N commits ending in S?)

I read man gitrevisions backwards and forwards; didn't find anything.

like image 345
Kaz Avatar asked Jun 18 '26 11:06

Kaz


1 Answers

I think you are searching for <tree-ish>^!

See gitrevisions documentation for details:

Repeated for convenience:

<rev>^!, e.g. HEAD^!

A suffix ^ followed by an exclamation mark is the same as giving commit <rev> and then all its parents prefixed with ^ to exclude them (and their ancestors).

Not as easy to understand, but I am quite certain it is what you are searching for.

But I don't see a generalized way to do this.

like image 54
AnimiVulpis Avatar answered Jun 20 '26 07:06

AnimiVulpis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!