These Git commands help you visualize and explore your project's commit history, with options for displaying a graphical representation, listing branches, and controlling the level of detail in the output.
npm run import -- "interesting git commands"
git log --graph --oneline --decorate --all
git log --graph --all
git show-branch --list
bash
#!/bin/bash
# Function to print Git log with graph, oneline, and decorate
show_git_log() {
git log --graph --oneline --decorate --all
}
# Function to print Git log with graph and all commits
show_git_commits() {
git log --graph --all
}
# Function to print Git show-branch with list
show_git_show_branch() {
git show-branch --list
}
# Main function to call other functions
main() {
# Print Git log with graph, oneline, and decorate
echo "Git Log with Graph, Oneline, and Decorate:"
show_git_log
# Print Git log with graph and all commits
echo -e "\nGit Log with Graph and All Commits:"
show_git_commits
# Print Git show-branch with list
echo -e "\nGit Show-branch with List:"
show_git_show_branch
}
# Call main function
main
# TODO: Add error handling for Git commands
# TODO: Implement logging for Git commands
These are Git commands used for visualizing and navigating your project's commit history. Let's break them down:
1. git log --graph --oneline --decorate --all
git log
: This is the core command for viewing commit history.--graph
: Displays a graphical representation of the commit history as a tree-like structure.--oneline
: Shows each commit on a single line, making the output more concise.--decorate
: Adds information about branches to the commit messages (e.g., master
, develop
).--all
: Includes commits from all branches, not just the current one.2. git log --graph --all
--oneline
and --decorate
flags. This will show a more detailed log with multiple lines per commit.3. git show-branch --list
git show-branch
: This command is used to list all branches in your repository.--list
: Displays a simple list of branch names.In Summary: