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.
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:
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.email "your-email@example.com"
You can verify the configuration using:
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:
This creates a hidden .git directory
containing Git's internal repository information.
Git Working Areas
Understanding Git's working areas is important for beginners.
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.
First Git Project
Let's create a simple project.
cd selenium-project
git init
Create a file such as:
Then check the repository 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.
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:
To stage all changed files:
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.
A good commit message should briefly explain what was changed.
Examples:
git commit -m "Fix checkout validation"
git commit -m "Update test configuration"
View Git History
Use the following command to view previous commits:
A shorter format can be displayed using:
Practical Git Workflow
A basic Git workflow looks like this:
git add .
git commit -m "Add new test cases"
This cycle can be repeated whenever you make a meaningful set of changes.
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
|
+-- 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:
To switch to the branch:
Modern Git also provides:
You can create and switch to a new branch in one command:
View Branches
The current branch is normally marked in the output.
Rename a Branch
To rename the current branch:
Switch Between Branches
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:
You can check configured remotes using:
Git Push
The git push command uploads your local
commits to a remote repository.
For a new branch:
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:
Cloning is commonly used when joining an existing project.
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.
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.
|
| Pull Request
v
main
GitHub describes pull requests as a workflow for proposing, reviewing and
eventually merging changes from a branch or fork.
Typical Pull Request Workflow
Create a feature branch
Create a separate branch for the required feature or test change.
Make code changes
Develop or modify the required automation code.
Run tests
Run the appropriate tests locally before committing.
Commit the changes
Save the completed changes with a meaningful commit message.
Push the branch
Upload your branch and commits to the remote repository.
Create a pull request
Open a PR from the feature branch to the team's target branch.
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 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:
// Version A
}
and:
// 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
- Run the merge or pull operation.
- Identify files with conflicts.
- Open the conflicted files.
- Review the conflicting sections.
- Keep or combine the correct changes.
- Remove conflict markers.
- Save the file.
- Stage the resolved file.
- Complete the merge according to the workflow.
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.
To inspect staged changes:
Git Restore
Git restore can be used to restore working-tree files.
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.
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.
This is often useful when you want to undo a previously committed change
while preserving the existing history.
- 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:
.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.
Git Tags
Tags can be used to mark specific points in repository history, such as
release versions.
git push origin v1.0.0
Git Stash
Git stash temporarily stores working changes so that you can switch
context without committing incomplete work.
To view stashed changes:
To restore the latest stash:
GitHub Repository Structure
A typical automation repository may look like this:
│
├── 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.
Clone the Automation Repository
Move Into the Project
Create a Feature Branch
Develop the Test
Create or modify your Selenium, Playwright or API automation code.
Check Changes
git diff
Run Tests
Execute the appropriate automation tests locally before committing
your changes.
Stage Changes
Commit
Push the Branch
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.
|
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.
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
## 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:
Instead of:
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 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
- Create an automation project.
- Initialize Git.
- Create a README file.
- Create a .gitignore file.
- Commit the initial framework.
- Create a feature branch.
- Add a login test.
- Commit the test.
- Push the branch to GitHub.
- Create a pull request.
- Review the changes.
- 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.
Official Resources
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
--git-primary-soft: #eef2ff;
--git-text: #1f2937;
--git-heading: #111827;
--git-muted: #64748b;
--git-border: #e2e8f0;
--git-background: #f8fafc;
--git-card: #ffffff;
--git-success: #047857;
--git-success-bg: #ecfdf5;
--git-warning: #b45309;
--git-warning-bg: #fffbeb;
--git-danger: #b91c1c;
--git-danger-bg: #fef2f2;
--git-info-bg: #eff6ff;
--git-code-bg: #111827;
max-width: 920px;
margin: 0 auto;
color: var(--git-text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
font-size: 17px;
line-height: 1.78;
box-sizing: border-box;
}
.git-guide *,
.git-guide *::before,
.git-guide *::after {
box-sizing: border-box;
}
.git-guide p {
margin: 0 0 18px;
}
.git-guide h1,
.git-guide h2,
.git-guide h3,
.git-guide h4 {
color: var(--git-heading);
line-height: 1.3;
margin-top: 0;
}
.git-guide h1 {
font-size: clamp(30px, 5vw, 44px);
margin-bottom: 20px;
letter-spacing: -0.8px;
}
.git-guide h2 {
font-size: clamp(25px, 4vw, 32px);
margin: 42px 0 18px;
padding-bottom: 10px;
border-bottom: 1px solid var(--git-border);
}
.git-guide h3 {
font-size: 22px;
margin: 30px 0 12px;
}
.git-guide h4 {
font-size: 18px;
margin: 24px 0 10px;
}
.git-guide a {
color: var(--git-primary-dark);
font-weight: 600;
text-decoration: none;
}
.git-guide a:hover {
text-decoration: underline;
}
.git-guide ul,
.git-guide ol {
margin: 12px 0 22px;
padding-left: 24px;
}
.git-guide li {
margin-bottom: 8px;
}
.git-guide strong {
color: var(--git-heading);
}
.git-guide .article-title {
margin-bottom: 10px;
}
.git-guide .article-subtitle {
color: var(--git-muted);
font-size: 18px;
margin-bottom: 24px;
}
.git-guide .article-intro {
background: linear-gradient(
135deg,
var(--git-primary-soft),
#ffffff
);
border: 1px solid #c7d2fe;
border-left: 5px solid var(--git-primary);
border-radius: 16px;
padding: 24px 26px;
margin: 24px 0;
}
.git-guide .article-intro p:last-child {
margin-bottom: 0;
}
.git-guide .article-summary,
.git-guide .info-box,
.git-guide .tip-box,
.git-guide .warning-box,
.git-guide .example-box,
.git-guide .key-takeaway,
.git-guide .checklist-box,
.git-guide .cta-box,
.git-guide .source-box {
border-radius: 14px;
padding: 20px 22px;
margin: 24px 0;
border: 1px solid var(--git-border);
background: var(--git-card);
box-shadow: 0 5px 18px rgba(15, 23, 42, 0.05);
}
.git-guide .article-summary {
background: var(--git-background);
}
.git-guide .info-box {
border-left: 4px solid #2563eb;
background: var(--git-info-bg);
}
.git-guide .tip-box {
border-left: 4px solid var(--git-success);
background: var(--git-success-bg);
}
.git-guide .warning-box {
border-left: 4px solid var(--git-warning);
background: var(--git-warning-bg);
}
.git-guide .example-box {
border-left: 4px solid var(--git-primary);
background: #f5f3ff;
}
.git-guide .key-takeaway {
border-left: 4px solid var(--git-success);
background: #f0fdf4;
}
.git-guide .checklist-box {
background: #ffffff;
}
.git-guide .article-summary h3,
.git-guide .info-box h3,
.git-guide .tip-box h3,
.git-guide .warning-box h3,
.git-guide .example-box h3,
.git-guide .key-takeaway h3,
.git-guide .checklist-box h3 {
margin-top: 0;
}
.git-guide .code-block {
position: relative;
overflow-x: auto;
background: var(--git-code-bg);
color: #e5e7eb;
border-radius: 12px;
padding: 18px 20px;
margin: 18px 0 24px;
font-family: Consolas, Monaco, "Courier New", monospace;
font-size: 14px;
line-height: 1.65;
white-space: pre;
border: 1px solid #1f2937;
}
.git-guide .inline-code {
font-family: Consolas, Monaco, "Courier New", monospace;
background: #f1f5f9;
color: #be123c;
border-radius: 5px;
padding: 2px 6px;
font-size: 0.92em;
}
.git-guide .table-wrapper {
width: 100%;
overflow-x: auto;
margin: 20px 0 28px;
border: 1px solid var(--git-border);
border-radius: 12px;
}
.git-guide .comparison-table {
width: 100%;
min-width: 580px;
border-collapse: collapse;
background: #ffffff;
}
.git-guide .comparison-table th {
background: var(--git-primary);
color: #ffffff;
text-align: left;
font-weight: 700;
padding: 13px 15px;
}
.git-guide .comparison-table td {
padding: 13px 15px;
border-top: 1px solid var(--git-border);
vertical-align: top;
}
.git-guide .comparison-table tr:nth-child(even) td {
background: #f8fafc;
}
.git-guide .step-card {
display: flex;
gap: 16px;
align-items: flex-start;
padding: 18px;
margin: 14px 0;
border: 1px solid var(--git-border);
border-radius: 13px;
background: #ffffff;
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}
.git-guide .step-number {
flex: 0 0 38px;
height: 38px;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: var(--git-primary);
color: #ffffff;
font-weight: 700;
}
.git-guide .step-card h3 {
margin: 0 0 6px;
font-size: 19px;
}
.git-guide .step-card p {
margin-bottom: 0;
}
.git-guide .highlight-text {
color: var(--git-primary-dark);
font-weight: 700;
}
.git-guide .image-container {
margin: 28px 0;
text-align: center;
}
.git-guide .image-container img {
display: block;
width: 100%;
max-width: 900px;
height: auto;
margin: 0 auto;
border-radius: 14px;
border: 1px solid var(--git-border);
}
.git-guide .image-caption {
color: var(--git-muted);
font-size: 14px;
margin-top: 8px;
}
.git-guide .ad-placeholder {
margin: 28px 0;
min-height: 90px;
}
.git-guide .faq-section {
margin-top: 36px;
}
.git-guide .faq-item {
border: 1px solid var(--git-border);
border-radius: 13px;
background: #ffffff;
padding: 19px 20px;
margin: 14px 0;
}
.git-guide .faq-item h3 {
font-size: 19px;
margin: 0 0 8px;
}
.git-guide .faq-item p:last-child {
margin-bottom: 0;
}
.git-guide .cta-box {
text-align: center;
background: var(--git-primary-soft);
border-color: #c7d2fe;
}
.git-guide .cta-box h3 {
margin-top: 0;
}
.git-guide .source-box {
background: #f8fafc;
}
.git-guide .source-box ul {
margin-bottom: 0;
}
.git-guide .article-divider {
height: 1px;
background: var(--git-border);
margin: 36px 0;
}
@media (max-width: 768px) {
.git-guide {
font-size: 16px;
line-height: 1.7;
}
.git-guide h2 {
margin-top: 34px;
}
.git-guide .article-intro,
.git-guide .article-summary,
.git-guide .info-box,
.git-guide .tip-box,
.git-guide .warning-box,
.git-guide .example-box,
.git-guide .key-takeaway,
.git-guide .checklist-box,
.git-guide .cta-box,
.git-guide .source-box {
padding: 17px;
border-radius: 12px;
}
.git-guide .code-block {
font-size: 13px;
padding: 15px;
border-radius: 10px;
}
.git-guide .step-card {
padding: 15px;
}
.git-guide .step-number {
flex-basis: 34px;
height: 34px;
}
.git-guide .comparison-table {
min-width: 540px;
}
}
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.
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:
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.email “your-email@example.com”
You can verify the configuration using:
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:
This creates a hidden .git directory
containing Git’s internal repository information.
Git Working Areas
Understanding Git’s working areas is important for beginners.
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.
First Git Project
Let’s create a simple project.
cd selenium-project
git init
Create a file such as:
Then check the repository 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.
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:
To stage all changed files:
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.
A good commit message should briefly explain what was changed.
Examples:
git commit -m “Fix checkout validation”
git commit -m “Update test configuration”
View Git History
Use the following command to view previous commits:
A shorter format can be displayed using:
Practical Git Workflow
A basic Git workflow looks like this:
git add .
git commit -m “Add new test cases”
This cycle can be repeated whenever you make a meaningful set of changes.
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
|
+– 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:
To switch to the branch:
Modern Git also provides:
You can create and switch to a new branch in one command:
View Branches
The current branch is normally marked in the output.
Rename a Branch
To rename the current branch:
Switch Between Branches
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:
You can check configured remotes using:
Git Push
The git push command uploads your local
commits to a remote repository.
For a new branch:
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:
Cloning is commonly used when joining an existing project.
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.
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.
|
| 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
Create a feature branch
Create a separate branch for the required feature or test change.
Make code changes
Develop or modify the required automation code.
Run tests
Run the appropriate tests locally before committing.
Commit the changes
Save the completed changes with a meaningful commit message.
Push the branch
Upload your branch and commits to the remote repository.
Create a pull request
Open a PR from the feature branch to the team’s target branch.
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 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:
// Version A
}
and:
// 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
- Run the merge or pull operation.
- Identify files with conflicts.
- Open the conflicted files.
- Review the conflicting sections.
- Keep or combine the correct changes.
- Remove conflict markers.
- Save the file.
- Stage the resolved file.
- Complete the merge according to the workflow.
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.
To inspect staged changes:
Git Restore
Git restore can be used to restore working-tree files.
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.
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.
This is often useful when you want to undo a previously committed change
while preserving the existing history.
- 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:
.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 push origin v1.0.0
Git Stash
Git stash temporarily stores working changes so that you can switch
context without committing incomplete work.
To view stashed changes:
To restore the latest stash:
GitHub Repository Structure
A typical automation repository may look like this:
│
├── 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.
Clone the Automation Repository
Move Into the Project
Create a Feature Branch
Develop the Test
Create or modify your Selenium, Playwright or API automation code.
Check Changes
git diff
Run Tests
Execute the appropriate automation tests locally before committing
your changes.
Stage Changes
Commit
Push the Branch
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.
|
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.
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
## 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:
Instead of:
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 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
- Create an automation project.
- Initialize Git.
- Create a README file.
- Create a .gitignore file.
- Commit the initial framework.
- Create a feature branch.
- Add a login test.
- Commit the test.
- Push the branch to GitHub.
- Create a pull request.
- Review the changes.
- 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.
Official Resources
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
