Git & GitHub for Beginners: Complete Guide with Practical Examples

Git & GitHub for Beginners: Complete Guide with Practical Examples

A practical beginner-friendly guide to Git, GitHub, branches, commits, pull requests, merge conflicts and Git workflows for QA testers and SDETs.

Git and GitHub are essential tools for modern software development and testing teams. Whether you are a fresher, QA tester, automation engineer, developer or aspiring SDET, understanding Git can help you manage code, collaborate with teams and maintain automation projects effectively.

Git allows you to track changes in your files and maintain different versions of your project. GitHub provides a platform where Git repositories can be hosted, shared and collaborated on with other team members.

In this complete beginner-friendly guide, you will learn what Git is, what GitHub is, how Git works, important Git commands, branches, commits, pull requests, merge conflicts, practical examples and how testers can use Git in automation projects.

Quick Summary

  • Git is a distributed version control system.
  • GitHub is a platform for hosting and collaborating on Git repositories.
  • The basic Git workflow is Working Directory → Staging Area → Local Repository → Remote Repository.
  • Branches allow developers and testers to work on separate changes.
  • Pull requests provide a workflow for reviewing and merging changes.
  • Git is useful for Selenium, Playwright, API automation and CI/CD projects.
  • Testers should understand commands such as status, add, commit, pull, push, merge and diff.

What Is Git?

Git is a distributed version control system used to track changes in files and manage different versions of a project.

Simple Example

Imagine you are developing a Selenium automation framework. You make changes to your login test today, modify the framework tomorrow and accidentally break something the following day.

Without version control, finding and recovering previous working versions can be difficult.

With Git, you can create commits representing different points in the project's history and return to earlier versions when necessary.

What Is GitHub?

GitHub is a platform for hosting Git repositories and collaborating on software projects.

Git and GitHub are related but they are not the same thing.

Git GitHub
Version control system Platform for hosting and collaboration
Runs locally on your computer Provides remote repositories
Tracks file changes Hosts Git repositories online
Works through Git commands Provides pull requests, issues and collaboration features

Why Should Testers Learn Git?

Git is particularly important for automation testers because test scripts and frameworks are software projects too.

A QA or SDET may use Git to:

  • Store Selenium or Playwright automation code.
  • Track changes to test scripts.
  • Create branches for new features.
  • Collaborate with developers and testers.
  • Review automation code.
  • Restore previous versions.
  • Manage framework changes.
  • Work with CI/CD pipelines.
  • Connect repositories with Jenkins or GitHub Actions.
Key Takeaway: Git is not only a developer tool. Automation frameworks, test scripts, configuration files and CI/CD definitions are also code that can benefit from version control.

Git Installation

Before using Git commands, install Git on your computer. The official Git documentation provides installation guidance for supported platforms.

After installation, verify it from the terminal:

git --version

If Git is installed correctly, the terminal displays the installed Git version.

Learn more about installing Git

Configure Git

After installing Git, configure your name and email address. Git uses this identity when creating commits. The official Git documentation recommends configuring your identity as part of the first-time setup.

git config --global user.name "Your Name" git config --global user.email "your-email@example.com"

You can verify the configuration using:

git config --list
💡 Pro Tip: Configure your Git identity before starting your first project so that your commits contain the expected author information.

Git Repository

A Git repository is a project directory that Git tracks.

To create a new Git repository inside an existing project:

git init

This creates a hidden .git directory containing Git's internal repository information.

Git Working Areas

Understanding Git's working areas is important for beginners.

Git workflow:

Working Directory → Staging Area → Local Repository → Remote Repository

Working Directory

This is where you create and modify your project files.

Staging Area

The staging area contains changes that you want to include in your next commit.

Local Repository

The local repository stores committed versions of your project on your computer.

Remote Repository

A remote repository can be hosted on platforms such as GitHub and allows team members to collaborate.

Recommended graphic: Git working directory → staging area → local repository → remote repository.

First Git Project

Let's create a simple project.

mkdir selenium-project cd selenium-project git init

Create a file such as:

LoginTest.java

Then check the repository status:

git status

Git will show the file as an untracked file.

What Is git status?

The git status command shows the current state of your working directory and staging area.

git status

It can help you identify:

  • Modified files
  • Untracked files
  • Staged files
  • Changes that are ready to commit

Git Add

To move a file into the staging area:

git add LoginTest.java

To stage all changed files:

git add .

The dot means that changes in the current directory are included according to Git's pathspec rules.

Git Commit

A commit records staged changes in the local Git repository.

git commit -m "Add login test"

A good commit message should briefly explain what was changed.

Examples:

git commit -m "Add login automation test" git commit -m "Fix checkout validation" git commit -m "Update test configuration"

View Git History

Use the following command to view previous commits:

git log

A shorter format can be displayed using:

git log --oneline

Practical Git Workflow

A basic Git workflow looks like this:

git status git add . git commit -m "Add new test cases"

This cycle can be repeated whenever you make a meaningful set of changes.

Key Takeaway: A simple mental model for beginners is: check → stage → commit.

What Is a Git Branch?

A branch provides an independent line of development. Branches allow developers and testers to work on different changes without immediately modifying the main branch.

Example

main | +-- login-test | +-- checkout-test | +-- payment-test

A tester could create a branch for a new automation feature while the main branch remains stable.

Creating a Git Branch

To create a new branch:

git branch login-test

To switch to the branch:

git checkout login-test

Modern Git also provides:

git switch login-test

You can create and switch to a new branch in one command:

git switch -c login-test

View Branches

git branch

The current branch is normally marked in the output.

Rename a Branch

To rename the current branch:

git branch -M main

Switch Between Branches

git switch main git switch login-test

Switching branches allows you to move between different lines of development.

What Is a Remote Repository?

A remote repository is a Git repository stored somewhere outside your local computer, such as a GitHub repository.

You can connect your local repository to a remote repository using:

git remote add origin YOUR_REPOSITORY_URL

You can check configured remotes using:

git remote -v

Git Push

The git push command uploads your local commits to a remote repository.

git push origin main

For a new branch:

git push -u origin login-test

The -u option establishes an upstream relationship so future pushes can often be performed using a shorter command.

Git Clone

If a project already exists on GitHub, you can download a copy of its repository using:

git clone YOUR_REPOSITORY_URL

Cloning is commonly used when joining an existing project.

QA Example:

A new QA team member may clone the company's automation repository before starting work.

Git Pull

The git pull command retrieves changes from a remote repository and integrates them into the current branch.

git pull origin main

Before starting work, team members often synchronize their local branch with the latest remote changes according to the team's workflow.

Git Fetch vs Git Pull

git fetch git pull
Downloads remote updates Downloads remote updates and integrates them
Does not automatically change your current branch Can update the current branch
Useful for inspecting remote changes first Useful when you want to synchronize directly

What Is a Pull Request?

A Pull Request (PR) is a request to merge changes from one branch into another branch on a collaborative Git hosting platform.

login-test branch | | Pull Request v main

GitHub describes pull requests as a workflow for proposing, reviewing and eventually merging changes from a branch or fork. :chatgpt-content-reference{index="10"}

Typical Pull Request Workflow

1

Create a feature branch

Create a separate branch for the required feature or test change.

2

Make code changes

Develop or modify the required automation code.

3

Run tests

Run the appropriate tests locally before committing.

4

Commit the changes

Save the completed changes with a meaningful commit message.

5

Push the branch

Upload your branch and commits to the remote repository.

6

Create a pull request

Open a PR from the feature branch to the team's target branch.

7

Review and merge

Team members review the changes, comments are addressed and the PR is merged according to repository policies.

Git Merge

Merge combines changes from one branch into another branch.

For example, after completing a login automation feature:

git switch main git merge login-test

The actual merge strategy used by a team may vary depending on repository policies and workflow.

Merge Conflicts

A merge conflict can occur when Git cannot automatically combine changes from different branches, often because different branches modify overlapping parts of the same file.

Example

Two testers modify the same method:

public void login() { // Version A }

and:

public void login() { // Version B }

Git may require a developer or tester to decide which changes should remain or how they should be combined.

Basic Conflict Resolution Process

  1. Run the merge or pull operation.
  2. Identify files with conflicts.
  3. Open the conflicted files.
  4. Review the conflicting sections.
  5. Keep or combine the correct changes.
  6. Remove conflict markers.
  7. Save the file.
  8. Stage the resolved file.
  9. Complete the merge according to the workflow.
⚠️ Important: Always review a conflict carefully. Do not automatically keep one side without understanding what the conflicting changes are intended to do.

Git Diff

The git diff command helps you inspect changes that have not been staged.

git diff

To inspect staged changes:

git diff --staged

Git Restore

Git restore can be used to restore working-tree files.

git restore LoginTest.java

Be careful when discarding changes because the command can remove modifications that have not been committed elsewhere.

Git Reset

Git reset can move the current branch reference and, depending on the selected mode, modify the staging area and working tree.

git reset HEAD~1

Because reset can affect commit history and working state, beginners should understand the selected mode before using it on important work.

Git Revert

Git revert creates a new commit that reverses the effect of an earlier commit.

git revert COMMIT_ID

This is often useful when you want to undo a previously committed change while preserving the existing history.

Remember the difference:
  • restore — restores files or staged content.
  • reset — can move the branch reference and alter history depending on the mode.
  • revert — creates a new commit that reverses an earlier commit.

.gitignore File

The .gitignore file tells Git which files or directories should generally not be tracked.

A Java automation project might contain:

target/ .idea/ *.class *.log .env

Depending on the project, configuration files containing passwords, API keys or other secrets should never be committed to a public repository.

GitHub also provides documentation for configuring .gitignore files. :chatgpt-content-reference{index="11"}

Git Tags

Tags can be used to mark specific points in repository history, such as release versions.

git tag v1.0.0 git push origin v1.0.0

Git Stash

Git stash temporarily stores working changes so that you can switch context without committing incomplete work.

git stash

To view stashed changes:

git stash list

To restore the latest stash:

git stash pop

GitHub Repository Structure

A typical automation repository may look like this:

automation-framework/ │ ├── src/ ├── test/ ├── pom.xml ├── README.md ├── .gitignore └── testng.xml

The exact structure depends on the framework and project requirements.

Git Workflow for QA Testers

Let's understand a practical Git workflow for an automation tester.

1

Clone the Automation Repository

git clone YOUR_REPOSITORY_URL
2

Move Into the Project

cd automation-framework
3

Create a Feature Branch

git switch -c login-automation
4

Develop the Test

Create or modify your Selenium, Playwright or API automation code.

5

Check Changes

git status git diff
6

Run Tests

Execute the appropriate automation tests locally before committing your changes.

7

Stage Changes

git add .
8

Commit

git commit -m "Add login automation tests"
9

Push the Branch

git push -u origin login-automation
10

Create Pull Request

Create a pull request from your feature branch to the team's target branch and provide a clear description of the changes and testing performed.

Continue learning: SDET Interview Preparation Roadmap

Git Commands Every Tester Should Know

Command Purpose
git init Initialize a repository
git clone Copy a remote repository locally
git status Check repository status
git add Stage changes
git commit Record staged changes
git log View commit history
git branch View or manage branches
git switch Switch branches
git merge Combine branch histories
git pull Fetch and integrate remote changes
git push Upload local commits
git fetch Download remote updates
git diff View changes
git stash Temporarily store working changes
git revert Create a commit that reverses another commit

Git and CI/CD

Git is an important component of modern CI/CD workflows.

Developer / Tester | v Git | v GitHub | v CI Server | v Build + Automated Tests | v Test Reports

For example, a tester pushes automation code to GitHub. A CI system such as Jenkins can then retrieve the code, build the project and execute automated tests according to the configured pipeline.

Key Takeaway: Git becomes especially valuable when your automation framework is connected to CI/CD because changes can move from version control into automated build and testing workflows.

GitHub for Automation Testers

GitHub can also help testers demonstrate their practical skills to potential employers.

You can create repositories containing:

  • Selenium automation projects.
  • Playwright projects.
  • API automation projects.
  • TestNG frameworks.
  • Page Object Model examples.
  • SQL practice queries.
  • Testing documentation.
  • CI/CD pipeline examples.

A well-organized GitHub repository can make your practical work easier for others to review.

How to Create a Good Automation GitHub Repository

A professional automation repository should ideally contain:

  • ✓ Clear project name
  • ✓ README file
  • ✓ Project description
  • ✓ Technology stack
  • ✓ Setup instructions
  • ✓ How to execute tests
  • ✓ Project structure
  • ✓ Sample test reports where appropriate
  • ✓ .gitignore file
  • ✓ No passwords or API secrets

Example README Structure

# Selenium Automation Framework ## About Automation framework for web application testing. ## Technologies - Java - Selenium - TestNG - Maven - Git ## Features - Page Object Model - Data-driven testing - Test reports - Reusable utilities ## How to Run mvn test

Git Best Practices for Testers

1. Write Meaningful Commit Messages

Prefer:

git commit -m "Add checkout validation tests"

Instead of:

git commit -m "changes"

2. Create Feature Branches

Avoid making every change directly on the main branch when the team workflow expects feature branches.

3. Pull Latest Changes Before Starting Work

Synchronize with the appropriate remote branch according to your team's process.

4. Keep Commits Focused

Try to keep related changes together rather than mixing unrelated modifications into one large commit.

5. Never Commit Secrets

Do not commit passwords, access tokens, private keys or other sensitive credentials.

6. Review Changes Before Committing

git status git diff

This can help catch accidental changes before they enter the repository history.

Related learning: Java Programming for Testers

Git Interview Questions for Testers

1. What is Git?

Git is a distributed version control system used to track changes and manage versions of files.

2. What is GitHub?

GitHub is a platform that hosts Git repositories and provides collaboration features such as pull requests and code review.

3. What is the difference between Git and GitHub?

Git is the version control system, while GitHub is a platform used to host and collaborate on Git repositories.

4. What is a Git repository?

A Git repository is a project managed by Git that contains its tracked files and version history.

5. What is a commit?

A commit records staged changes in the local repository along with a commit message.

6. What is a branch?

A branch is an independent line of development that allows changes to be developed separately from another branch.

7. What is git pull?

Git pull fetches changes from a remote repository and integrates them into the current branch according to the configured Git workflow.

8. What is git push?

Git push uploads local commits to a remote repository.

9. What is git clone?

Git clone creates a local copy of an existing remote repository.

10. What is a merge conflict?

A merge conflict occurs when Git cannot automatically combine changes from different histories, often because overlapping parts of a file were modified differently.

11. What is git stash?

Git stash temporarily stores working changes so that you can change context without committing those incomplete changes.

12. What is .gitignore?

.gitignore specifies files and directories that Git should generally not track.

13. What is a pull request?

A pull request is a request to merge changes from one branch into another branch for review and integration.

14. What is the difference between git fetch and git pull?

Fetch downloads remote updates without automatically integrating them into the current branch, while pull performs a fetch followed by integration according to the configured behavior.

7-Day Git Learning Plan for Testers

Day Topics
Day 1 Git fundamentals and installation
Day 2 init, status, add, commit and log
Day 3 Branches and switching
Day 4 GitHub repositories, clone, push and pull
Day 5 Merge, conflicts, fetch and pull requests
Day 6 Stash, revert, restore, .gitignore and tags
Day 7 Build and publish a small automation project

Practical Project for Beginners

After learning the commands, create a small Selenium or Playwright automation project.

Suggested Project Workflow

  1. Create an automation project.
  2. Initialize Git.
  3. Create a README file.
  4. Create a .gitignore file.
  5. Commit the initial framework.
  6. Create a feature branch.
  7. Add a login test.
  8. Commit the test.
  9. Push the branch to GitHub.
  10. Create a pull request.
  11. Review the changes.
  12. Merge the branch according to your chosen workflow.

This project gives you practical experience that can be discussed during QA and SDET interviews.

Continue your preparation with: Playwright + TypeScript Roadmap

Frequently Asked Questions

Is Git difficult for beginners?

The basic Git workflow is relatively straightforward once you understand working directory, staging area, commits, branches and remote repositories. Regular practice is the best way to become comfortable with Git.

Should testers learn Git?

Git is a practical skill for managing automation code and collaborating with development and QA teams.

Is GitHub required for Selenium?

GitHub is not required to run Selenium, but it is useful for storing, sharing and collaborating on Selenium automation projects.

What Git commands should a fresher know?

Start with git clone, git init, git status, git add, git commit, git log, git branch, git switch, git pull, git push, git merge and git diff. Then learn stash, revert, restore and fetch.

Can Git help in getting an SDET job?

Git itself does not guarantee employment, but Git knowledge is a practical skill for working with automation frameworks and demonstrating software development practices.

Conclusion

Git and GitHub are important skills for anyone entering modern software testing and automation. Testers frequently work with automation frameworks, test scripts, configuration files and CI/CD pipelines, making version control an important part of their daily workflow.

Start by learning the basic workflow:

Clone → Create Branch → Make Changes → Status → Add → Commit → Push → Pull Request → Review → Merge

Once you understand this workflow, practice it with a real Selenium, Playwright or API automation project. Practical usage will help you remember Git commands much more effectively than memorizing them.

If you are preparing for a QA or SDET role, continue with the SDET Interview Preparation Roadmap .

Keep Learning

Explore more career, technology and interview preparation guides on DVGHM.

Related Testing & Career Guides

Keywords: Git and GitHub for beginners, Git tutorial for beginners, Git commands, GitHub tutorial, Git for testers, Git for QA, Git for SDET, Git interview questions, GitHub for testers, Git workflow, Git branches, Git pull request, Git merge conflict, version control for testers

Popular posts from this blog

Amazon Jobs 2026: Latest Hiring for HR, IT Support & Case Manager Roles

Deloitte Hiring 2026: Research & Account Management Associate – Hyderabad

Zoho Hiring 2026: Technical Support Engineer Jobs for Freshers