Sitemap
Akhila Korthiwada

Akhila Korthiwada

Git Learning series — Config, reset and amend Explained (Git Basics- Part2)

5 min readMar 26, 2026

--

Press enter or click to view image in full size

Hello, Welcome to Day 12 of my DevOps learning journey!

This blog is a continuation of my Git learning series. If you’re new to Git or haven’t read the introduction yet, I suggest starting from my previous post Read here to build a strong foundation.

In this article, I’ll walk through three essential Git commands:

  • git config → Setting up your identity
  • git commit --amend → Fixing commit mistakes
  • git reset → Managing and removing files properly

Git Configuration

What is git config?

Think of Git like a new phone you just bought .

Before using it, what do you do?

  1. Set your name
  2. Add your email
  3. Choose your preferences

git config is exactly that — it helps you set your identity and preferences in Git.

Why Git Needs Configuration?

Imagine this situation: You make a commit in Git… But Git asks: “Who made this change? ”

Without config, Git doesn’t know:

  • Your name
  • Your email

So your commits won’t have proper identity . So the Purpose of git config is to Identify the Author

Every commit stores:

  • Your name
  • Your email

git config is a powerful command in Git. You can use the Git configuration file to customize how Git works. This file exists in the project level where Git is initialized (/project/.git/config) or at the root level (~/.gitconfig). If no configurations are specified, Git uses its default settings.

To set the Author, run the following commands

git config --global user.name "Akhila" # sets the user name
git config --global user.email "akhila@example.com" # sets the mail id of the user

How to Check Your Config

git config --list #Shows all your settings

You can set preferences like: Default Editor, Command Shortcuts, Colors in terminal

Example:

git config --global core.editor "vim" # Sets default editor as vim
git config --global color.ui auto  # automatically use colors when supported

Lets move on and learn git amend

Git Amend

What is git commit — amend?

The “Oops, I Forgot the Salt!” Guide to git commit — amend

Imagine you’re baking cookies. You’ve mixed the dough and popped them in the oven (that’s your Commit). Suddenly, you see the salt sitting on the counter. You forgot it!

In the real world, you’d have to bake a second, separate batch. In Git, git commit — amend lets you pause time, toss the salt into the same batch, and pretend you never forgot it. It’s your “do-over” button for your most recent commit.

Scenario 1: You forgot to include a file

If you committed your code but realized you left out styles.css:
1. Stage the file: git add styles.css
2. Amend the commit: git commit — amend — no-edit

Get Akhila Korthiwada’s stories in your inbox

Join Medium for free to get updates from this writer.

What happens: Git “opens” the last commit, drops the new file inside, and seals it back up. The — no-edit flag tells Git to keep the original commit message. The command to add missed files to existing commit

git commit --amend --no-edit # This will combine the currently staged changes with the previous commit

Scenario 2: You made a typo in the message

If you committed with the message “Fixxed bug” and want to look professional:
Run the command: git commit — amend -m “Fixed bug”
What happens: Git replaces the old, typo-ridden commit with a brand new one containing the correct text.

git commit --amend -m "Fixed bug" # edits the commit message of latest commit

Scenario 3: Changing Author Info

Imagine you’re baking at a friend’s house and accidentally sign the recipe card with their name instead of yours. In Git, this happens if you commit using a work email instead of a personal one (or vice versa).

The Workflow:
Run the identity command:

git commit - amend - author="Your Name <email@example.com>" - no-edit #modifies author details of previous commit
git commit - amend - author="Your Name <email@example.com>" # The next commits reflects this new Author details

What just happened?
Git reaches into the last commit, swaps out the “Author” metadata with your correct details, and keeps the code and message exactly as they were ( — no-edit).

If you don’t want to change already committed Author but for the next commits you want to change the Author use the command without no-edit.

Git Reset

What is git reset?

git reset is used to undo commits or move your project back to a previous state when something goes wrong. It helps developers fix mistakes, rework changes, or clean up commit history before sharing code with the team.

Imagine you are making a dough for baking cookies, you added a whole cup of salt instead of teaspoon. You need to go back to the moment before salt touched the bowl

Undo Changes with git reset

You made multiple commits, but now you realize:
This entire change is wrong. I need to undo it.

git reset --hard HEAD~1 # Deletes latest commit AND changes permanently
git reset --hard HEAD~2 # Deletes latest 2 commits AND changes permanently

Types of Reset:

Soft Reset : Removes last commit but keeps changes ready to commit

Hard Reset : Deletes commit AND changes permanently

OK, You used git reset --hard and lost your commit

Is it gone forever?

No! Recover Lost Work with git reflog

What is git reflog?

You used git reset — hard to delete a buggy feature, but then you realized that buried in that “bad” code was a genius algorithm you spent three days writing. You think it’s gone forever.

Now, you want to brink back that one deleted commit

git reflog #shows the history of all actions performed in your repository—even the ones you “deleted”.

How it works: Git keeps a hidden log of every single move you make, even the ones you “deleted.” Get the commit Id of that particular commit you deleted and Recover Your Commit by again running

git reset --hard commitId #Bring back only that file’s content from that commit

or you can use cherry pick to undo that particular changes

git cherry-pick commitId #Safely restore only that change

What git cherry-pick Does

It allows you to pick a specific commit and apply it to your current changes.

Conclusion

Day 12 learning felt like unlocking Git’s advanced control system. At first, these commands seem risky — but once understood, they give you confidence to handle any mistake in a project.

What’s Next?

In the next blog, I’ll continue exploring more real-world Git workflows and commands used in development teams.

Thank you so much for taking the time to read my blog! 🌼✨

See you in next learning blog!!

--

--