Git commands that every software tester should know

Since git is vastly used among version control systems, every software tester should know or become familiar with using it.

What git does?

It manages and keeps track of changes on different branches. Compares changes between each one. It’s purpose is to manage source code.

The way git works is three-tree architecture. 1. Repository, 2. Staging index, 3. Local branch (working branch)

User clones repository to his local disk -> Creates new working branch and starts working -> After certain changes have been made user adds those new changes into staging index -> Commit/Push changes into repository.

Clone GitHub repository

git clone => This will clone repository to your local disk.

Clone repository

Create new local branch

git branch <NAME_OF_YOUR_NEW_BRANCH> => Create new branch locally

Delete branch

git branch -d <NAME_OF_THE_BRANCH> => Delete local branch

git push origin --delete <NAME_OF_THE_BRANCH> => Delete remote branch

Push change to a branch

git status=> Check the status of your branch to see if any files have been changed

git add .=> Add all files to a staging index

git add YOUR_FILE=> Add just that one file to staging index

git commit -m ”YOUR_MESSAGE”=> Commit your code change

git push => Push changes to a remote branch

git push -u origin <NAME_OF_YOUR_LOCAL_BRANCH> => Push changes from the local branch to the remote branch

Where Am I?

git branch => See on which branch you are

Switch to another branch

git checkout <NAME_OF_OTHER_BRANCH> => Switch to other branch

Pull latest

git pull => Pull all the latest stuff from remote branch into your local branch

Merge branch

Let’s say you were writing new automated test for certain feature, and that took some time. You would like to merge all the latest from branch master into your working branch XY. You can git checkout master to a master branch, do a git pull, and then git checkout XY. After that you can do a git merge master, and this will merge all the new stuff from master branch into the branch XY.



git log=> See changes someone has committed

git log --since=2017-01-14=> Displayed commits from that date to today

git log --until=2017-01-14=> Display commits up to that date

git log --author="SOME_USER"=> Display commits from SOME_USER


In .gitignore file you can make a list of all the files you don’t want to be seen by git. Git will pretend they are not there.

For example, if you don’t want to log files to be tracked you can add a line in gitignore file *.log , this will ignore all files with .log extension.

More examples:

.vagrant => Ignores .vagrant file

tests/output => Ignores everything inside the output directory

.idea => This will ignore JetBrains idea file

/tmp => This will ignore temp files

That’s it, enjoy testing and #ApplyQuality

Sharing is caring! Please hit that ❤ and share this article with anyone who might benefit from it.