Skip to content

Instantly share code, notes, and snippets.

@jglick
Created October 20, 2017 19:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jglick/66974651f7c0c3ffed5945b3f2d2ebd4 to your computer and use it in GitHub Desktop.
Save jglick/66974651f7c0c3ffed5945b3f2d2ebd4 to your computer and use it in GitHub Desktop.
git first-child
[alias]
# http://stackoverflow.com/a/30010601/12916
first-child = "!f() { git log --reverse --ancestry-path --pretty=%H $1..${2:-HEAD} | head -1; }; f"
@jglick
Copy link
Author

jglick commented Oct 20, 2017

Taken from this tip.

Useful as a branch point for Maven projects; e.g.,

git checkout -b 1.23.x `git first-child this-project-1.23`
mvn versions:set -DnewVersion=1.23.1-SNAPSHOT
git commit -a -m 'Prep for 1.23.1'

retains

<tag>HEAD</tag>

and anything else besides <version>s that might have changed in the [maven-release-plugin] prepare for next development iteration commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment