🐙
Git Developer Guide
About
  • Overview
  • Scope of this book
  • Table of Content
  • 🐢Introduction to Version Control
    • What is Version Control?
    • Overview of git and it's benefits
    • Setting up Git on Different Platforms
  • 🍼Git Fundamentals
    • Initialising a new Git repository
    • Understanding the Git Workflow
    • Committing Changes and Writing Good Commit Messages
    • Viewing and Navigating Commit History
    • Git Basics - Practice Scenarios
      • Initialising a Git Repository
      • Committing Changes
      • Exploring Commit History
      • Amending and Undoing Commits
  • 🦕Working With Git
    • What is Git Branch?
    • Creating and Switching Between Branches
    • Merging Branches and Resolving Conflicts
    • Best Practices for Branch Management
    • Git Workflows
    • Git Log
    • Git Stash
    • Working with Git - Practice Scenarios
      • Creating and Switching Between Branches
      • Merging Branches and Resolving Conflicts
      • Branching Strategies in a Team Project
      • Rolling Back to a Previous Version
      • Experimenting with Feature Branches
      • Working with Stash
  • 🤝Working with Remote Repositories
    • Cloning a Repository from Remote
    • Pushing and Pulling Changes to and from Remote Repositories
    • Collaborative Workflows - Forking, Branching, and Pull Requests
    • Resolving Conflicts in a Collaborative Environment
    • Collaborating with Git - Practice Scenarios
      • Cloning a Remote Repository
      • Pushing and Pulling Changes
      • Collaborative Workflow with Forking and Pull Requests
      • Resolving Conflicts in a Pull Request
  • 🏆Advanced Git Features
    • Aliases and Custom Configurations
    • Working with Tags and Releases
    • Rewriting Commit History with Interactive Rebase
    • Utilising Git Hooks for Automation
    • Advanced Git Features - Practice Scenarios
      • Creating Custom Git Aliases
      • Working with Tags and Releases
      • Rewriting Commit History with Interactive Rebase
      • Using Git Hooks for Automated Testing
  • 😎Git in Real-World
    • Managing a Project with Multiple Contributors
    • Integrating Git with Continuous Integration, Continuous Deployment (CI, CD)
    • Versioning Assets with Git LFS (Large File Storage)
    • Deploying a Web Application using Git
    • Git In Real World - Practice Scenarios
      • Managing a Project with Multiple Contributors
      • Integrating Git with CICD Pipelines
      • Versioning Assets with Git LFS
      • Deploying a Web Application using Git
  • Git Troubleshooting
    • Common Mistakes and Pitfalls When Using Git
    • Undoing Changes with Git - Reverting and Resetting
    • Recovering Lost Commits or Branches
    • Dealing with Repository Corruption or Other Issues
  • Git Best Practices and Tips
    • Creating efficient git workflows: writing clean code for faster reviews
    • The importance of clean code in collaborative development
    • Significance of consistent naming conventions & coding Standards
    • Good code documentation for better git workflows
    • Writing meaningful git commit messages
    • Atomic commits in git & it's benefits for software teams
    • Structuring code & managing dependencies for better git workflows
    • Git branching strategies for software teams
  • Conclusion & Next Steps
    • Recap of Key Concepts and Commands
    • Further Resources for Expanding Git Knowledge
    • Encouragement and Tips for Continued Learning and Practice
  • License Considerations
Powered by GitBook
On this page

Was this helpful?

  1. Working With Git

Git Log

Git provides a powerful command called git log that allows you to visualise the branch history and explore the commits made in a repository

Using Git Log to Visualise Branch History

In a collaborative software development project, understanding the branch history is crucial for effective collaboration and tracking the progress of different features or bug fixes.

In this section, we will dive into the details of utilising git log to view branch history and how to leverage its options for filtering and formatting log output.

Viewing Branch History

To view the branch history, navigate to your project's repository directory using the command line or terminal and run the following command:

git log

By default, this command displays a list of commits in reverse chronological order, starting with the latest commit. Each commit is represented by a commit hash, author information, date, and commit message.

To visualise the branch history as a graphical representation, we can utilise an additional option, --graph, which draws ASCII art to depict the commits and their relationships. This graphical representation helps us understand the branching and merging that has taken place.

git log --graph

The output will show branches as lines that extend from commits, allowing you to visualise the commit history and the branching structure. Each commit is represented by a node, and the lines connecting them indicate the relationship between the commits.

Filtering Log Output for Specific Branches

Sometimes, we may want to focus on a specific branch's history to understand its development or review the changes made on that branch. Git provides options to filter the log output based on branches.

To view the history of a specific branch, use the --branches option followed by the branch name:

git log --branches=<branch-name>

For example, to view the history of the "develop" branch, run the following command:

git log --branches=develop

This will display only the commits related to the "develop" branch, allowing you to inspect the branch's history in isolation.

To filter the log output for multiple branches, you can pass multiple --branches options:

git log --branches=<branch1> --branches=<branch2>

Formatting Log Output

Git log provides flexible options to format the output according to your needs. You can specify the format using the --pretty option followed by a format placeholder.

For example, to display only the commit hash and commit message for each commit, you can use the --pretty=format option:

git log --pretty=format:"%h %s"

This will show the abbreviated commit hash (%h) and the commit message (%s) for each commit.

Benefits of Understanding Branch History

Understanding branch history using git log has several benefits for both individual developers and collaborative projects:

  1. Project Understanding: By visualising the branch history, you can gain insights into the overall project structure, identify significant milestones, and understand how different features or bug fixes have evolved over time.

  2. Code Review: When collaborating with other developers, reviewing the branch history allows you to track the changes made in a branch and provide more contextual and informed code reviews. It helps in understanding the rationale behind certain decisions or modifications.

  3. Debugging and Issue Tracking: When troubleshooting issues or investigating bugs, branch history can provide valuable information about the sequence of commits and changes that led to the problem. This can aid in identifying the root cause and finding potential solutions.

  4. Merge and Rebase Strategies: Viewing branch history helps in determining the most appropriate merge or rebase strategies. By examining the commit history, you can better understand the impact of merging or rebasing a branch and anticipate any potential conflicts.

By using git log and exploring the branch history, you can improve your understanding of the project, collaborate effectively with others, and make informed decisions related to code changes and project management.

PreviousGit WorkflowsNextGit Stash

Last updated 1 year ago

Was this helpful?

You can find a comprehensive list of format placeholders in the . By using different placeholders, you can customise the output to include information such as author, date, and more.

🦕
Git documentation