0
0
Gitdevops~30 mins

Viewing commit history with git log - Mini Project: Build & Apply

Choose your learning style9 modes available
Viewing commit history with git log
📖 Scenario: You are working on a small project and want to see the history of changes made to your files. This helps you understand what was changed and when.
🎯 Goal: Learn how to use the git log command to view the commit history of a Git repository.
📋 What You'll Learn
Initialize a Git repository
Make at least two commits
Use git log to view commit history
💡 Why This Matters
🌍 Real World
Viewing commit history helps developers track changes, find bugs, and understand project progress.
💼 Career
Knowing how to use <code>git log</code> is essential for software developers, DevOps engineers, and anyone working with version control.
Progress0 / 4 steps
1
Initialize a Git repository and create commits
Run git init to create a new Git repository. Then create a file named file.txt with the content Hello. Add the file with git add file.txt and commit it with the message First commit. Next, change the content of file.txt to Hello, world!, add it again, and commit with the message Second commit.
Git
Need a hint?

Use git init to start the repository. Use echo to write text to the file. Use git add and git commit -m to save changes.

2
Set up a configuration to limit log output
Create a variable called log_limit and set it to 1. This will be used to limit the number of commits shown in the log.
Git
Need a hint?

Use log_limit=1 to create the variable.

3
Use git log with the limit option
Run the command git log -n $log_limit to show only the most recent commit in the history.
Git
Need a hint?

Use git log -n $log_limit to limit the number of commits shown.

4
Display the full commit history
Run git log without any limit to see all commits in the repository.
Git
Need a hint?

Simply run git log to see all commits.