Introduction
Welcome to Day 16 of the #100DaysOfDevOps challenge! Today, we're diving into the world of Git-GitHub commands.
git remote
:
Explanation:
git remote
is used to manage connections to remote repositories. It doesn't affect your local repository but helps you configure and interact with remote counterparts. You can have multiple remotes, each with a unique name.Usage Examples:
git remote -v # Lists remote repositories with their URLs git remote add <name> <url> # Adds a new remote repository git remote remove <name> # Removes a remote repository
git merge
:Explanation:
git merge
combines changes from one branch into another. It creates a new commit that incorporates the changes, maintaining a unified branch history.
Usage Example:
git merge feature-branch # Merges changes from 'feature-branch' into the current branch
git cherry-pick
:Explanation:
git cherry-pick
allows you to apply a specific commit from one branch to another.It's useful when you want to selectively include changes from one branch into another.
Before cherry-picking need to fetch the latest changes to the local branch.
Usage Example:
git cherry-pick <commit_hash> # Applies changes from the specified commit
git log
:Explanation:
git log
displays the commit history, showing details like commit hash, author, date and commit message. It's a powerful tool for understanding project history.
Usage Example:
git log # Displays the commit history
Customize log output (e.g., show only specific branches, limit the number of commits, etc.):
Common Options:
--oneline
: Condenses each commit to a single line.--graph
: Displays an ASCII graph representing branch and merge history.--all
: Shows the entire commit history, including all branches.- Example:
git log --oneline --graph --all
git show
:Explanation:
git show
displays information about a specific commit, including changes introduced by that commit.
Usage:
Basic usage to display information about the latest commit
Show information about a specific commit:
Common Options:
<commit_hash>
: Specifies the commit you want to show.
Example:
git show abc123
Output:
- The output of
git show
includes metadata about the commit (author, date, etc.) and a unified diff of the changes made in that commit.
- The output of
git show
command with custom formatting options to display specific information about a particular commit. However, there's a small mistake in your command. The correct usage would be:git show --format="%an|%ad" --date="format:%Y-%m-%d %H:%M:%S" --no-patch c3334e04cbf0cef3b
Here's a breakdown of the options you're using:
--format="%an|%ad"
: Specifies the format for displaying the author's name (%an
) and author date (%ad
).--date="format:%Y-%m-%d %H:%M:%S"
: Specifies the format for displaying the date in a specific format.--no-patch
: Excludes the actual code changes from the output.
This command will show information about the specified commit (c3334e04cbf0cef3b
), including the author's name, author date, and the specified date format.
git show --pretty="" --name-only <commit>
command is used to display specific information about a commit.