Quick Git Commands
Introduction
In this post, I will show some basic git commands.
Commands
git commit
This one of the most important commands in git, it’s used to create a commit. Using it without any flags will open the text editor, making it easy to write a detailled description of the commit.
> git commit
# Your branch is up to date with 'origin/main'.
#
# Changes to be committed:
# new file: content/posts/quick-git-commands.md
#
This is the commit's message that explains the changes briefly
This is the commit's description that explains the changes it brings.
You can write on multiple lines what was done and why it was done.
> git log
commit 4f5c8b76e880f0fe7e18f0bd1fe860c843ea12da (HEAD -> main)
Author: D14rn <49399494+D14rn@users.noreply.github.com>
Date: Sun Nov 24 17:16:02 2024 +0100
This is my commit message that explains the changes briefly
This is my commit description that explains the changes made
I can write in multiple lines what I did and why I did it
git commit –amend
This one is useful whenever you realize you made a (small) mistake after creating a commit, it enables you to add staged files to the previous commit, but also enables you to simply modify the commit’s message/description. This modification replaces the old commit with a new one, so be careful.