Essential GIT Commands for Software Developers.

Savindu Pasintha
2 min readJan 14, 2024

I sense your interest in becoming a software engineer. In that case, it’s crucial to familiarize yourself with the following Git commands.

Before delving into the details, take a moment to imagine a scenario:

Your repository consists of two branches, named ‘a’ &‘b’.

Main Three States:

  1. Working Directory:
  • git status: Check the status of your working directory and see which files are modified.
  1. Staging Area:
  • git add <file>: Stage changes in the specified file for the next commit.
  • git add . or git add -A: Stage all changes in the working directory.
  1. Repository:
  • git commit -m "Your commit message": Commit staged changes to the repository.

Git Stashing:

  1. Stash Changes:
  • git stash save "Your stash message": Save your changes to a stash.
  1. List Stashes:
  • git stash list: View a list of your stashes.
  1. Apply Stash:
  • git stash apply: Apply the latest stash.
  • git stash apply stash@{2}: Apply a specific stash.
  1. Pop Stash:
  • git stash pop: Apply the latest stash and remove it from the stash list.
  1. Drop Stash:
  • git stash drop stash@{2}: Discard a specific stash.
  1. Clear All Stashes:
  • git stash clear: Remove all stashes.

Git Rebase:

  1. Rebase Interactive:
  • git rebase -i <branch>: Start an interactive rebase on the specified branch.
  1. Continue Rebase:
  • After resolving conflicts during a rebase:
  • git add <conflicted-file>: Stage the resolved file.
  • git rebase --continue: Continue with the rebase.
  1. Abort Rebase:
  • git rebase --abort: Abort the ongoing rebase.

--

--