0
0
Gitdevops~15 mins

git blame for line-by-line history - Mini Project: Build & Apply

Choose your learning style9 modes available
git blame for line-by-line history
📖 Scenario: You are working on a small project with a file called app.py. You want to find out who last changed each line in this file to understand the history better.
🎯 Goal: Learn how to use git blame to see line-by-line history of changes in a file.
📋 What You'll Learn
Have a git repository initialized
Have a file named app.py with at least 3 lines of code
Use git blame to see who last changed each line
💡 Why This Matters
🌍 Real World
Developers often need to find out who last changed a specific line of code to understand why a change was made or to ask questions.
💼 Career
Knowing how to use <code>git blame</code> is essential for debugging, code reviews, and collaborating in software development teams.
Progress0 / 4 steps
1
Create a file app.py with 3 lines of code
Create a file called app.py with these exact lines:
print('Hello World')
print('Welcome to git blame')
print('This is line 3')
Git
Need a hint?

Use a text editor or command line to create app.py with the exact lines.

2
Add and commit the file to git
Add the file app.py to git staging area using git add app.py and commit it with the message Initial commit with app.py using git commit -m "Initial commit with app.py"
Git
Need a hint?

Use git add to stage and git commit -m to commit with the exact message.

3
Modify the second line in app.py
Change the second line in app.py to print('Welcome to the git blame tutorial') exactly, then add and commit the change with message Update welcome message
Git
Need a hint?

Edit the file to change the second line exactly, then stage and commit with the exact message.

4
Use git blame to see line-by-line history of app.py
Run the command git blame app.py to display who last changed each line in app.py.
Git
Need a hint?

Simply run git blame app.py to see the line-by-line history.