VOOZH about

URL: https://www.javacodegeeks.com/2019/01/selecting-git-commits-message.html

⇱ Selecting Git commits by message - Java Code Geeks


In order to checkout, cherry-pick, or reset Git commits, you don’t have to provide their SHA commit hash. All commits can be referred to by their message, by using the pattern :/<part-of-message>, which comes in very handy when using Git from the command line.

Given the following commit history:

caeb1d8 (HEAD) commit 4
2f6d4da commit 3
8207cf2 commit 2
551ef47 commit 1
22f759b initial commit

We can checkout commit 551ef47 by git checkout ':/commit 1'.

The pattern will search the history backwards, for the first commit where the provided string is part of the commit’s message. Therefore, It’s also possible to do git checkout :/initial in order to checkout 22f759b.

This post was reposted from my newsletter issue 024.

Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Selecting Git commits by message

Opinions expressed by Java Code Geeks contributors are their own.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Thank you!

We will contact you soon.

Tags
Git
πŸ‘ Photo of Sebastian Daschner
Sebastian Daschner
January 26th, 2019Last Updated: January 25th, 2019
0 123 1 minute read

Sebastian Daschner

Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.
Subscribe

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button
Close
wpDiscuz