Task 11 don’t have the hint. Kindly check. Here’s the lab URL and the Task:
The repository has many commits. Can you try to list the last 3 commits alone?
There should be an option in git log
to limit the list of outputs. Use git help log
. Check hint if not sure.
You can use
git log --help
to see how to use it
And the bit you’re concerned with is this in the help
$ git log A...B
which means “get me the entries from commit A to commit B”
A
and B
can be either commit hashes or the special notation HEAD
which means the head of the branch i.e. the last commit done
So to get the last 3 commits we do
git log HEAD~3...HEAD
which means the entries between 3rd commit before HEAD and HEAD inclusive.
Try it.
Thank you @Alistair_KodeKloud for the explanation.
I guess the flags below from section “Commit Limiting” of “git log --help” serves the same purpose. Please correct me if I am wrong:
-<number>, -n <number>, --max-count=<number>
Limit the number of commits to output.
Yes, that would also work and is quicker!
Reading the command help/documentation is always a Very Good Thing ![:slight_smile: :slight_smile:](https://kodekloud.com/community/images/emoji/twitter/slight_smile.png?v=12)
One of the key skills in DevOps is how to find information, as you’ll often be asked to implement something that is not currently known about in the workplace so you won’t necessarily have colleagues with experience in a given topic to ask.
1 Like