The git log command is one of the most essential tools in Git. It allows you to view the commit history of a repository, showing you who made changes, when they made them, and what message they included.
Think of it as a "journal" or "timeline" of your project's life.
1. Basic Usage
When you run the command without any arguments, it shows the history in reverse chronological order (newest first).
git log
What you will see:
Commit Hash: A unique 40-character string (SHA-1) that identifies the commit.
Author: The name and email of the person who made the change.
Date: When the commit was created.
Commit Message: The description provided by the author.
2. Common Variations (Examples)
Sometimes the default output is too long or contains too much information. You can use flags to filter or format the output.
A. One-Line Summary
If you want a quick overview of many commits at once, use --oneline. It condenses each commit to a single line showing just the short hash and the message.
git log --oneline
B. Limiting the Number of Commits
To see only the last 3 commits:
git log -n 3
C. Showing Changes (Patch)
If you want to see the actual code changes (the "diff") introduced in each commit:
git log -p
D. Visualizing Branches (The Graph)
In complex projects with many branches, this command shows a visual ASCII graph of how branches merge and diverge.
git log --oneline --graph --all
3. Filtering the History
You can also search for specific commits based on different criteria:
| Requirement | Command |
| By Author | git log --author="John" |
| By Date | git log --since="2 weeks ago" |
| By Message | git log --grep="fix bug" |
| By File | git log -- index.html (only shows changes to that file) |
Summary Checklist
Purpose: View the history of the project.
Key Info: Who, when, and what was changed.
Navigation: When viewing a long log, use the Arrow Keys to scroll and press q to quit and return to the terminal.
Git లో git log అనేది మీ ప్రాజెక్ట్ యొక్క చరిత్రను (Commit History) చూడటానికి ఉపయోగపడే అతి ముఖ్యమైన కమాండ్. మీ ప్రాజెక్ట్లో ఎవరెవరు మార్పులు చేశారు, ఎప్పుడు చేశారు మరియు ఆ మార్పుల ఉద్దేశ్యం ఏమిటి అనేది ఇది ఒక "డైరీ" లేదా "టైమ్లైన్" లాగా చూపిస్తుంది.
1. ప్రాథమిక ఉపయోగం (Basic Usage)
మీరు టెర్మినల్లో ఈ కమాండ్ టైప్ చేసినప్పుడు, ఇటీవల జరిగిన మార్పుల నుండి పాత వాటి వరకు వరుసగా కనిపిస్తాయి.
git log
ఇది చూపే వివరాలు:
Commit Hash: ప్రతి మార్పుకు కేటాయించిన ఒక యూనిక్ ఐడెంటిఫికేషన్ నంబర్ (ఉదా: 40 అక్షరాల SHA-1 స్ట్రింగ్).
Author: మార్పు చేసిన వ్యక్తి పేరు మరియు ఈమెయిల్.
Date: ఆ మార్పు ఏ రోజు, ఏ సమయానికి జరిగిందో చూపిస్తుంది.
Commit Message: ఆ మార్పు గురించి డెవలపర్ రాసిన వివరణ.
2. ముఖ్యమైన ఉదాహరణలు (Common Examples)
కొన్నిసార్లు పూర్తి సమాచారం అవసరం లేనప్పుడు, ఈ క్రింది రకాలుగా git logను వాడవచ్చు:
A. ఒక్క లైన్ లో చూడటానికి (One-Line Summary)
చాలా కమిట్స్ ఉన్నప్పుడు, క్లుప్తంగా చూడటానికి ఇది ఉపయోగపడుతుంది.
git log --oneline
B. పరిమిత సంఖ్యలో చూడటానికి (Limiting Commits)
చివరిగా జరిగిన 3 మార్పులను మాత్రమే చూడాలంటే:
git log -n 3
C. కోడ్ మార్పులతో సహా చూడటానికి (Patch)
ఏ ఫైల్లో ఏ లైన్ మార్చారో (Diff) వివరంగా చూడటానికి:
git log -p
D. గ్రాఫ్ రూపంలో చూడటానికి (Visualizing Branches)
ప్రాజెక్ట్లో వేర్వేరు బ్రాంచ్లు ఎలా విడిపోయాయో, ఎలా కలిసాయో బొమ్మలా చూడటానికి:
git log --oneline --graph --all
3. ఫిల్టర్ చేయడం (Filtering the History)
మీకు కావలసిన నిర్దిష్ట వివరాల కోసం ఇలా సెర్చ్ చేయవచ్చు:
| అవసరం | కమాండ్ |
| ఒక వ్యక్తి చేసినవి | git log --author="John" |
| నిర్దిష్ట కాలానికి చెందినవి | git log --since="2 weeks ago" |
| మెసేజ్ ఆధారంగా | git log --grep="fix bug" |
| ఒక ఫైల్కు సంబంధించినవి | git log -- index.html |
ముఖ్య గమనిక:
git logరిజల్ట్స్ ఎక్కువగా ఉన్నప్పుడు టెర్మినల్ నుండి బయటకు రావడానికి కీబోర్డులో q బటన్ను ప్రెస్ చేయండి.పైకి, క్రిందకు స్క్రోల్ చేయడానికి Arrow Keys ఉపయోగించండి.

No comments:
Post a Comment
Note: only a member of this blog may post a comment.