I have a text file (.yml) that I enter some texts to my system use. But now we need to know what new lines at once. I thought to use git to solve our problem, but I cant find a clarified command to do this.
Is this possible?
You can get a list of the commits withs something like so:
git log --abbrev-commit --pretty=oneline
Which should something like this:
commitD Description
commitC Description
commitB Description
commitA Description
Choose your two commits and substitute them below:
git diff <commitA>..<commitB> -- /path/to/file
You can do it with one commandline:
git diff -w `git rev-list HEAD --reverse | head -1`..HEAD -- <path/file>
It does not work to use --reverse with a count of 1 (-1 / --max-count 1) ... as it reverses the resulting list after truncating it. So either you use --reverse together with the head command or you use tail -1.
I had to add the -w for my usage because of switches in line-endings and tab vs. spaces usage.
This may not work as expected if the file was not added in the first commit! You may change the above line to:
git diff -w `git rev-list HEAD --reverse -- <path/file> | head -1`..HEAD -- <path/file>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With