How to, TipsAndTricks

Quick Tip – How to display the history of a file using git ?

Hello ! I’m Xavier Jouvenot and in this small post, I am going to explain how to display the history of a file using git.

Self promotion: You can find other articles on Android development on my website 😉

Git log

You may be familiar or not with this the command git log which can display the history of the commit of your repository, when you use it at the root of your repository. But there is more about it !

Indeed, you can look to the documentation to see all the options available, and we are going to take a look at some of them.

For the problem targeted on this post, here is the command line solving it:

git log <path/to/your/file>

This command line will display your the details of each commit when the file has been modified.

If you want to only display the minimum of information to know retrieve the commit, you can add the flag oneline such as:

git log --oneline <path/to/your/file>

And if, on the contrary, you want to display more information such as the diff about the file involved in each of those commits, you can add the flag -p, like so:

git log -p <path/to/your/file>

Thank you all for reading this article, And until my next article, have a splendid day 😉

Interesting links

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google

Vous commentez à l’aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s