0
0
Gitdevops~15 mins

SHA-1 hashing concept in Git - Mini Project: Build & Apply

Choose your learning style9 modes available
SHA-1 Hashing Concept with Git
📖 Scenario: You are learning how Git uses SHA-1 hashes to identify commits uniquely. This helps Git track changes safely and efficiently.
🎯 Goal: You will create a simple text file, configure Git user info, commit the file, and then view the SHA-1 hash of the commit to understand how Git generates it.
📋 What You'll Learn
Create a file named example.txt with exact content Hello Git SHA-1
Configure Git user name as Test User and email as test@example.com
Add and commit the file with message Initial commit
Display the SHA-1 hash of the latest commit using git log
💡 Why This Matters
🌍 Real World
Git uses SHA-1 hashes to track every change in a project safely. This helps developers collaborate without conflicts.
💼 Career
Understanding SHA-1 hashes in Git is essential for software developers and DevOps engineers to manage code versions and troubleshoot issues.
Progress0 / 4 steps
1
Create the file with exact content
Create a file named example.txt with the exact content Hello Git SHA-1.
Git
Need a hint?

Use the echo command to write text into a file.

2
Configure Git user name and email
Configure Git user name as Test User and email as test@example.com using git config commands.
Git
Need a hint?

Use git config user.name "Your Name" and git config user.email "your.email@example.com".

3
Add and commit the file
Initialize a new Git repository using git init, add example.txt to Git staging area using git add example.txt and commit it with message Initial commit using git commit -m "Initial commit".
Git
Need a hint?

Use git init to initialize a repository, git add to stage files and git commit -m "message" to commit.

4
Display the SHA-1 hash of the latest commit
Use git log -1 --format=%H to display the SHA-1 hash of the latest commit.
Git
Need a hint?

The command git log -1 --format=%H shows the full SHA-1 hash of the latest commit.