Git — Useful Tips, Part One
DevOps useful Git operation tips
As a DevOps engineer, you can benefit from several useful Git tips to improve your workflow and collaboration with your team. Here are some tips that can help you become more efficient with Git.
Check Recent Commit
git show
is a Git command that displays information about a specific Git object, such as a commit, tag, or tree. By default, git show
displays the patch (or diff) representing the changes made in a commit, along with the commit message and metadata.
# Display the most recent commit
$ git show
commit a1234b56789cdef0123456789abcdef12345678 (HEAD -> main)
Author: John Doe <john.doe@example.com>
Date: Mon Jan 1 10:00:00 2023 -0400
Added a new feature
diff --git a/file1.txt b/file1.txt
index 1234567..89abcdef 100644
--- a/file1.txt
+++ b/file1.txt
@@ -1,3 +1,4 @@
...
Update Commit Message
git commit --amend --only -m
is a Git command that allows you to amend the last commit by updating only specific files in the commit and changing the commit message. The --only
option specifies that only certain files should be updated, and the -m
option allows you to provide a new commit message.
$ git commit --amend --only -m 'xxxxxxx'