Git for testers: a basic overview of commands

In this article, we provide an overview of the basic Git commands you need to know when working side-by-side with developers as an IT tester. They will enable you to work efficiently with the GIT repository, track code changes, and resolve conflicts. Git is a distributed version control system (DVCs) that is one of the best open-source tools for programmers. It enables project sharing and effective team collaboration. You can read more about what Git, GitHub, GitLab are in our last article. Although knowledge of Git is essential for developers and Automation Tester, manual testers often lack the knowledge to use it. That’s why we’re going to tell you more about Git commands now.

Git – basic terms

Before we get into using the individual commands, let’s explain the key terms associated with Git:

  • git repository: this is the repository where all the files and change history of the project are stored. The repository allows you to track and manage code changes, collaborate with developers, and easily revert to previous versions if needed. Each repository contains a complete history of all changes, providing transparency and control over the project’s development.
Repository type Description
Local repository This repository is stored on your computer. All operations such as commit, branch creation and merge are performed locally.
Remote repository This repository is hosted on a server such as GitHub, GitLab or Bitbucket.

It is used to share your project with other team members and to back up your data.

  • Commit: Commit is the basic element that Git uses to track the history of changes in a repository. It indicates an action that saves code changes to the Git repository, creating a new point in the project’s history.
  • Branch: this is a branch in the Git repository that represents a separate line of development. Branches allow you to work on different features or fixes independently of the main (usually “master” or “main”) branch, making parallel development and testing easier. Each branch can have its own history and changes, which can later be merged back into the main branch or into other branches.

Branches allow you to work on different functions or fixes independently of the main master or main branch, thus facilitating parallel development and testing.

  • Merge: the process of merging changes from one branch into another. Often used to integrate changes from development branches into the main branch.

Git Flow

Git Flow is a way to organize and manage work on a project using Git. It is used to structure the work in a team, making it easier to manage different features, patches, and software releases. The main features of Git Flow are:

  1. Master branch: this branch represents a stable version of the software that is ready for production. New versions of software are usually merged into this branch only after thorough testing and approval.
  2. Develop branch: this branch represents the active development branch into which all new features and changes are merged. It is where teams collaborate to develop new functionality and fixes.
  3. Feature branches: these branches are created to develop a specific functionality or feature of the software. Each feature is developed in a separate branch and when completed, it is merged into a develo branch.
  4. Release branches: these branches are created to prepare new versions of software for release. They contain final tests and preparations, such as documentation changes and version updates.
  5. Hotfix branches: these branches are created to fix critical bugs in a version of the software that is already in production. Hotfixes often have high priority and are merged into master and develop branches.

Installing and registering Git

To get started with Git, the first step is to install it. Visit the official Git website at git-scm.com. On the main page you will find the option to download the installation file for your operating system (git download). The next step is to create an account on the repository server. You have various free options like github, gitlab, bitbucket, and so on. Each of these options has its own features, but they all support git. If you have your own account, you can already create your own repositories or clone existing ones, create branches, etc.

Basic commands (git commands)

Now let’s look at a few basic commands:

Cloning a repository – git clone

If you want to work on an existing project, you can download (clone) it to your local computer. This command simply creates a copy of the remote repository on your local machine.

Merging changes – git merge

Git merge is used to merge changes from one branch into another, allowing integration of new features or bug fixes from different development lines. This process is crucial for updating the main development branch, resolving conflicts, ensuring continuous development, and managing of the repository history.

Saving changes – git commit

A Git commit is used to save the current changes in the working directory to the Git versioning system. Each commit creates a new record in the project history that captures the changes, their author, date, and description. In this way, commits allow you to keep a history of changes, document modifications, and track a project’s progress over time.

Synchronising changes – git pull and git push

  • git pull – a command that pulls the latest changes from a remote repository and integrates them into your local copy.
  • git push – a command that pushes local changes to a remote repository for other developers to see and use.

View commit history – git log

This command displays the commit history in the repository. You can get information about who made changes to the repository and when.

Viewing the status of a repository – git status

The git status command is used to display the current status of the repository. It provides an overview of which files are changed, which files are added to the staging area (ready to commit), and which files have not yet been tracked or are in a changed state. It also provides information about the current branch and whether there are any new updates in the repository from the remote repository.

Temporary storage – git stash

The git stash command is used to temporarily store your current changed or untracked files in a “stash”. The main use of git stash is in situations where you have unfinished changes in a branch, but need to move on to another task or solve another problem. So instead of committing pending changes, it’s better to use git stash to temporarily save the changes.

Arranging commits – git rebase

Git rebase allows you to relocate or “move” a series of commits from one branch to another. For example, if you’re working on your own functionality on a branch and you want to add changes that have happened on the main branch in the meantime, you can use a rebase. Your changes are then placed above the changes from the main branch, making your change history nice and easy to read.

Working with branches – git branch

Here are some of the main features of git branch:

  1. Creating a branch: you can create a new branch from the current working branch using git branch <branch_name>. This new branch will contain the current state of the repository, and you can switch to it without changing your main branch.
  2. Branch switching: Use git checkout <branch_name> to switch to another branch in the repository. This allows you to work on different parts of the project without affecting other branches.
  3. Branch browsing: git branch without arguments lists all the branches in the repository and highlights which one is current.
  4. Deleting a branch: if it is no longer needed, you can delete it with git branch -d <branch_name>. However, before deleting a branch, it’s important to make sure that any changes from that branch are included in other branches or are stored in the repository.

Practical tips

  1. Start with small changes: try simple changes and commits before going into complex operations
  2. Commit regularly: commit small changes often, this will make it easier to track changes.
  3. Use branches: create branches for different tasks or test scenarios to keep your main repository clean and transparent.
  4. Document your changes: always write meaningful commit messages so it is transparent what changes were made and why.
  5. Regularly synchronise with the origin: Regularly update your local repository with the origin to avoid conflicts and keep your project up-to-date.

Conclusion

Git is a powerful tool that can make your work much more efficient, even if you’re a manual tester. Knowing the basics will allow you to better collaborate with developers and automation testers, leading to better software quality and a more efficient testing process. Don’t be afraid to experiment and learn new things – Git is the tool that lets you do that without worrying about losing your job or making changes. I wish you the best of luck with Git!

If you speak German and are IT tester or Automation Tester, take a look at our employee benefits and respond to job offers.

About the author

Katarína Kučáková

Software Test Engineer

Moja cesta k testovaniu softvéru sa začala v roku 2019 až po štúdiu ekonómie a pracovných skúsenostiach v iných odvetviach. To mi pomohlo vnímať IT svet v rôznych súvislostiach. Ten totiž ponúka neustále nové výzvy, pre ktoré rada hľadám riešenia. Obľubujem oddych pri čítaní, turistiku alebo lyžovanie. LinkedIn

Let us know about you