← Back to Git Course | Chapter 2: Basic Commands | Lesson 11 of 18

Git log Command

git log photo album को सबसे नई picture से backward पलटने जैसा है, पढ़ते हुए कि हर एक किसने ली, कब, और caption क्या कहता है।
Syntax
bash
git log
git log --oneline
git log -n number
git log --author="name"

Commit History देखना

git log आपकी commit history में backward चलता है, सबसे नई पहले, हर commit का पूरा hash, author, date, और message print करते हुए -- सिर्फ एक quick overview चाहिए होने पर हर entry को एक single line में compress करने के लिए --oneline add करें।

उदाहरण: Viewing Commit History

bash
git log
git log --oneline

Log Output Limit करना

एक long-running project पर पूरा log हज़ारों entries तक फैल सकता है, इसलिए git log -n 5 (या कोई भी संख्या) output को सिर्फ सबसे हाल की commits तक limit करता है, जो आमतौर पर वही है जो actually आपको check करने के लिए चाहिए।

उदाहरण: Limiting the Log Output

bash
git log -n 5

Author से Logs Filter करना

एक team project पर, git log --author="name" history को एक specific person की commits तक filter करता है, जो किसी के हाल के काम को review करने या यह track करने के लिए उपयोगी है कि किसने एक particular area को छुआ।

उदाहरण: Filtering Logs by Author

bash
git log --author="Priya"

Date से Logs Filter करना

git log --since="2 weeks ago" --until="yesterday" (या specific dates) commits को एक date range तक filter करता है, जो exactly review करने का सबसे तेज़ तरीका है कि एक sprint के दौरान या एक release से पहले क्या बदला।

उदाहरण: Filtering Logs by Date

bash
git log --since="2 weeks ago" --until="yesterday"

Graphs से History Visualize करना

git log --graph --oneline --all एक ASCII diagram draw करता है कि आपकी branches समय के साथ कैसे diverge और merge हुईं, एक अन्यथा linear list को एक visual map में बदल देते हुए जो complex branching history follow करना कहीं आसान बना देता है।

उदाहरण: Visualizing History with Graphs

bash
git log --graph --oneline --all
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. पूरे git log output में scroll करना, जबकि git log --oneline प्रति commit एक line देता है।
  2. pager में गलत keys दबाना और यह न जानना कि q इससे exit करता है।
  3. यह उम्मीद करना कि git log दूसरी branches से commits दिखाएगा, जबकि यह सिर्फ current से reachable history दिखाता है जब तक आप --all इस्तेमाल न करें।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.