Whether you’re a seasoned automation tester / developer or just dipping your toes into version control, Git is an essential tool in your coding toolkit. It’s the magic that keeps track of your changes, allows you to collaborate seamlessly, and ensures that you can always go back in time to a working version of your code. But let’s face it: Git commands can seem a little intimidating at first.
Fear not! Let’s walk through the only Git commands you’ll ever need. By the end of this article, you’ll feel like a Git wizard—without all the cryptic spells. Let’s get started!
Why should you care about Git?
Imagine you’re writing a book with a team of authors. Everyone’s adding new chapters, tweaking existing ones, and trying to maintain consistency. Git is like the editor-in-chief who tracks every single change made, saves versions of each draft, and allows you to revert back to previous versions if needed. It’s like a time machine and collaboration tool, all rolled into one!
Now, let’s dive into the Git commands that’ll help you manage your code with ease.
Here’s a comprehensive list of Git commands, especially focused on the ones frequently used by automation testers:
Create a new commit that undoes a previous commit.
Fetching and Pulling Changes
Command
Description
git fetch
Fetch changes from the remote repository.
git pull origin <branch_name>
Pull changes from a remote branch.
Pushing Changes
Command
Description
git push origin <branch_name>
Push changes to a remote branch.
git push -f origin <branch_name>
Force push changes to a remote branch (use caution).
Merging and Rebasing
Command
Description
git merge <other_branch>
Merge changes from another branch.
git rebase <base_branch>
Rebase changes onto another branch.
git rebase -i HEAD~<number_of_commits>
Interactive rebase for squashing commits.
Branch Management
Command
Description
git branch
List all branches.
git branch -d <branch_name>
Delete a branch (merged).
git branch -D <branch_name>
Force delete a branch (use caution).
git branch -m <new_branch_name>
Rename the current branch.
git branch -a
List all branches, including remote branches.
Checking Repository Status
Command
Description
git status
Check the status of your repository.
git log
View commit history.
git log --oneline --graph --all
View a compact log with graphical representation.
git diff
Show changes between working directory and staging.
git diff --staged
Show changes between staging and the last commit.
git show <commit_hash>
Show details of a specific commit.
Remote Repository Management
Command
Description
git remote
List remote repositories.
git remote add <remote_name> <repository_url>
Add a new remote repository.
git remote -v
List remote repositories with URLs.
git remote show <remote_name>
Show information about a remote repository.
git remote remove <remote_name>
Remove a remote repository.
Git Tagging
Command
Description
git tag
List all tags.
git tag <tag_name>
Create a new tag.
git tag -a <tag_name> -m "Your tag message"
Create an annotated tag with a message.
git tag -d <tag_name>
Delete a tag.
git push origin <tag_name>
Push a tag to a remote repository.
git push origin --tags
Push all tags to a remote repository.
Miscellaneous Commands
Command
Description
git clean -n
Preview untracked files to be deleted.
git clean -f
Delete untracked files.
git stash
Temporarily save changes for later use.
git stash apply
Apply stashed changes back to the working directory.
git cherry-pick <commit_hash>
Apply changes from a specific commit.
git blame <file_name>
Show who changed each line in a file.
git grep "search_term"
Search for a term in your codebase.
Conclusion
Git might seem intimidating at first glance, but with the right commands and understanding, it’s an incredibly powerful tool that can streamline your workflow and give you control over your projects. By mastering the essential Git commands—like git init, git add, git commit, and git push—you’ll be able to manage your projects like a pro.
Whether you’re working solo or as part of a team, these commands will be your best friends. The more you practice, the more natural they’ll become, and soon, you’ll be navigating Git with ease.
Scientist Testbot, endlessly experimenting with testing frameworks, automation tools, and wild test cases in search of the most elusive bugs. Whether it's poking at flaky pipelines, dissecting Selenium scripts, or running clever Lambda-powered tests — QAbash.ai is always in the lab, always learning.
⚙️ Built for testers. Tuned for automation. Obsessed with quality.
With 13+ years in SDET leadership, I drive quality and innovation through Test Strategies and Automation. I lead Testing Center of Excellence, ensuring high-quality products across Frontend, Backend, and App Testing.
"Quality is in the details" defines my approach—creating seamless, impactful user experiences. I embrace challenges, learn from failure, and take risks to drive success.