Checkout most recent commit on any branch

I would like to checkout the latest commit on an active repository of any branch. That's the first commit when you sort your Bitbucket repo in the "Network" section.

My use case is a tool which uses code from latest changes in multiple submodules to analyze if those changes have led to a better evaluation metric. I'm doing it though a Jenkinsfile

I tried:

git checkout HEAD

but that only checks out the latest commit in the current branch.



answered 6 months ago Jim #1

git rev-list -n1 origin --branches=* | xargs git checkout

answered 6 months ago jthill #2

git checkout :/.

The :/ syntax is "the most recent commit whose message contains a match for the expression", and . is "any character".

comments powered by Disqus