Module 7: Remote Repositories: Collaborating on Test Automation
Connect your local test repository to remote platforms like GitHub and GitLab. Learn to push test changes, pull updates from teammates, manage remote branches, and collaborate effectively on shared test automation projects. Set up CI/CD integration basics for automated test execution.
Setting Up Remote Repositories and First Push
Why This Matters
As a test automation engineer, you’ve likely experienced the frustration of losing test code, accidentally overwriting a colleague’s work, or struggling to share automated tests across your team. Perhaps you’ve emailed test scripts back and forth, or worse, stored them only on your local machine where one hardware failure could wipe out weeks of work.
This lesson solves critical real-world challenges:
Version Control Disasters: Without remote repositories, your test automation code exists in isolation. One corrupted hard drive, one accidental deletion, and your entire test suite disappears. Remote repositories provide a safety net that every professional test engineer needs.
Team Collaboration Bottlenecks: When multiple QA engineers work on the same test framework, conflicts are inevitable. Who has the latest version? Which tests were updated? Remote repositories become the single source of truth that keeps your team synchronized.
CI/CD Integration Requirements: Modern software delivery demands automated testing in continuous integration pipelines. Your tests can’t run automatically if they’re trapped on your laptop. Remote repositories are the bridge between your local development and automated test execution in CI/CD systems.
You’ll use these skills:
- Daily: Pushing test updates and pulling teammate changes
- Multiple times per day: Syncing your local work with the team’s progress
- Weekly: Setting up new test projects and configuring CI/CD pipelines
- Every project: Establishing collaboration workflows for test development
Common pain points this lesson addresses:
- “How do I share my test automation framework with the team?”
- “What happens if my computer crashes and I lose all my tests?”
- “How do I get my tests running in our CI/CD pipeline?”
- “Someone else modified the same test file – how do we merge changes?”
- “How do I keep my local tests in sync with what’s on the server?”
What You’ll Accomplish
By the end of this lesson, you’ll transform from working in isolation to being a collaborative test automation engineer who can work seamlessly with distributed teams and automated pipelines.
Here’s how each learning objective builds your skills:
1. Connecting to Remote Platforms (GitHub/GitLab)
You’ll create accounts on GitHub or GitLab and learn to link your local test repository to these platforms. We’ll cover both HTTPS and SSH authentication methods, helping you choose the right approach for your security requirements. You’ll understand the git remote
command and how to verify your connections.
2. Executing Your First Push
You’ll push your test automation code to a remote repository for the first time. We’ll walk through the git push
command, understand remote branches, and troubleshoot common errors like rejected pushes. You’ll see your code appear on the remote platform’s web interface, confirming successful upload.
3. Pulling Updates from Remote
You’ll learn to retrieve changes made by teammates using git pull
and understand the difference between pull and fetch. We’ll cover merge conflicts that arise when multiple engineers modify the same test files and how to resolve them efficiently.
4. Managing Remote Branches You’ll track and manage branches across local and remote repositories. We’ll explore listing remote branches, switching between them, and understanding tracking relationships. You’ll learn how distributed teams use branches to work on features independently.
5. Setting Up Basic CI/CD Integration You’ll configure your first automated test execution trigger. We’ll set up a simple CI/CD workflow that runs your tests automatically when code is pushed. You’ll learn where test results appear and how to interpret pipeline status.
6. Establishing Collaboration Workflows You’ll implement best practices for team-based test development. We’ll cover commit message conventions, branching strategies for test automation, and communication patterns that prevent conflicts and confusion.
Each section includes hands-on exercises with your actual test repository, real error scenarios you’ll encounter, and solutions that work in professional environments. Let’s begin your journey to collaborative test automation.
Core Content
Core Content: Setting Up Remote Repositories and First Push
Core Concepts Explained
Understanding Remote Repositories
A remote repository is a version of your project hosted on the internet or network. It allows you to:
- Backup your code in the cloud
- Collaborate with team members
- Access your code from different machines
- Share your test automation projects
The most common remote repository platforms are:
- GitHub - Popular for open source and collaboration
- GitLab - Offers built-in CI/CD features
- Bitbucket - Integrates well with Atlassian tools
The Local-Remote Relationship
graph LR
A[Local Repository] -->|git push| B[Remote Repository]
B -->|git pull| A
C[Working Directory] --> A
B --> D[Team Members]
Your local repository exists on your computer, while the remote repository lives on a platform like GitHub. You push changes from local to remote and pull changes from remote to local.
Step-by-Step: Creating and Connecting to a Remote Repository
Step 1: Create a Remote Repository on GitHub
- Log into your GitHub account at https://github.com
- Click the "+" icon in the top right corner
- Select “New repository”
- Configure your repository:
- Repository name:
test-automation-project
- Description: “My first test automation project”
- Visibility: Public or Private (your choice)
- ⚠️ Important: Do NOT initialize with README, .gitignore, or license (we already have a local repo)
- Repository name:
- Click “Create repository”
<!-- SCREENSHOT_NEEDED: BROWSER
URL: https://github.com/new
Description: GitHub new repository creation form with fields filled out
Placement: After Step 1 instructions -->
Step 2: Initialize Your Local Repository
If you haven’t already initialized a local Git repository, do so now:
# Navigate to your test automation project directory
cd /path/to/your/test-automation-project
# Initialize Git repository
git init
# Verify initialization
git status
Expected output:
$ git init
Initialized empty Git repository in /path/to/your/test-automation-project/.git/
$ git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
Step 3: Add Your Remote Repository
After creating the repository on GitHub, connect it to your local repository:
# Add remote repository (use HTTPS or SSH)
git remote add origin https://github.com/YOUR_USERNAME/test-automation-project.git
# Verify the remote was added
git remote -v
Expected output:
$ git remote -v
origin https://github.com/YOUR_USERNAME/test-automation-project.git (fetch)
origin https://github.com/YOUR_USERNAME/test-automation-project.git (push)
Understanding the command:
git remote add
- Adds a new remote connectionorigin
- The conventional name for your primary remote repository- The URL - Points to your GitHub repository
Step 4: Create Your First Commit
Before pushing, you need to commit your test automation files:
# Check current status
git status
# Add all files to staging area
git add .
# Or add specific files
git add package.json tests/login.test.js
# Create your first commit
git commit -m "Initial commit: Add test automation project setup"
# Verify commit was created
git log --oneline
Expected output:
$ git commit -m "Initial commit: Add test automation project setup"
[main (root-commit) a1b2c3d] Initial commit: Add test automation project setup
5 files changed, 120 insertions(+)
create mode 100644 package.json
create mode 100644 tests/login.test.js
create mode 100644 playwright.config.js
$ git log --oneline
a1b2c3d (HEAD -> main) Initial commit: Add test automation project setup
Step 5: Push to Remote Repository
Now push your local commits to the remote repository:
# Push to remote repository (first time)
git push -u origin main
# For subsequent pushes, you can simply use
git push
Expected output:
$ git push -u origin main
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 1.24 KiB | 1.24 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/YOUR_USERNAME/test-automation-project.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
Understanding the command:
git push
- Uploads local commits to remote-u
- Sets upstream tracking (only needed first time)origin
- The remote namemain
- The branch name
sequenceDiagram
participant WD as Working Directory
participant SA as Staging Area
participant LR as Local Repository
participant RR as Remote Repository
WD->>SA: git add .
SA->>LR: git commit -m "message"
LR->>RR: git push origin main
Practical Code Examples
Complete Workflow Example: Test Automation Project
Here’s a complete example of setting up and pushing a test automation project for practiceautomatedtesting.com:
# 1. Create project directory
mkdir login-test-automation
cd login-test-automation
# 2. Initialize Node.js project
npm init -y
# 3. Install Playwright
npm install -D @playwright/test
# 4. Create test file
mkdir tests
tests/login.test.js:
// Login test for practiceautomatedtesting.com
const { test, expect } = require('@playwright/test');
test('successful login test', async ({ page }) => {
// Navigate to the practice website
await page.goto('https://practiceautomatedtesting.com/login');
// Fill in login credentials
await page.fill('#username', 'testuser');
await page.fill('#password', 'Test123!');
// Click login button
await page.click('button[type="submit"]');
// Verify successful login
await expect(page).toHaveURL(/.*dashboard/);
await expect(page.locator('.welcome-message')).toBeVisible();
});
playwright.config.js:
// Playwright configuration for test automation
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
testDir: './tests',
timeout: 30000,
use: {
baseURL: 'https://practiceautomatedtesting.com',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
});
Now commit and push:
# 5. Initialize Git repository
git init
# 6. Create .gitignore file
echo "node_modules/
test-results/
playwright-report/" > .gitignore
# 7. Stage all files
git add .
# 8. Create initial commit
git commit -m "Initial commit: Add login test automation with Playwright"
# 9. Add remote repository (created on GitHub)
git remote add origin https://github.com/YOUR_USERNAME/login-test-automation.git
# 10. Push to GitHub
git push -u origin main
Adding More Tests and Pushing Updates
# Create a new test file
touch tests/checkout.test.js
# Edit the file with your test code
# ... (add your test automation code)
# Check what changed
git status
# Stage the new test
git add tests/checkout.test.js
# Commit with descriptive message
git commit -m "Add checkout process test automation"
# Push to remote
git push
Expected output:
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
tests/checkout.test.js
$ git push
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 654 bytes | 654.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
To https://github.com/YOUR_USERNAME/login-test-automation.git
a1b2c3d..e4f5g6h main -> main
<!-- SCREENSHOT_NEEDED: BROWSER
URL: https://github.com/YOUR_USERNAME/login-test-automation
Description: GitHub repository showing committed files including tests directory
Placement: After push example -->
Common Mistakes Section
Mistake 1: Pushing Before Committing
❌ Wrong:
git add .
git push origin main # Error: nothing to push!
✅ Correct:
git add .
git commit -m "Add test files"
git push origin main
Why: You must commit changes locally before pushing to remote.
Mistake 2: Wrong Remote URL
Symptom: fatal: repository 'https://github.com/...' not found
Solution:
# Check current remote
git remote -v
# Remove incorrect remote
git remote remove origin
# Add correct remote
git remote add origin https://github.com/YOUR_ACTUAL_USERNAME/repo-name.git
Mistake 3: Authentication Errors
Symptom: Authentication failed
or Permission denied
Solutions:
For HTTPS (using Personal Access Token):
# GitHub no longer accepts passwords
# Use Personal Access Token instead
# Go to GitHub → Settings → Developer settings → Personal access tokens
# Generate token and use it as password
For SSH:
# Generate SSH key
ssh-keygen -t ed25519 -C "your_email@example.com"
# Add to SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Add public key to GitHub
# Copy key: cat ~/.ssh/id_ed25519.pub
# Go to GitHub → Settings → SSH and GPG keys → Add SSH key
# Change remote to SSH
git remote set-url origin git@github.com:YOUR_USERNAME/repo-name.git
Mistake 4: Branch Name Mismatch
Symptom: error: src refspec main does not match any
Solution:
# Check current branch name
git branch
# If branch is 'master' instead of 'main'
git branch -M main
# Then push
git push -u origin main
Mistake 5: Forgotten .gitignore
❌ Wrong: Committing node_modules/
folder (thousands of files)
✅ Correct: Always create .gitignore
before first commit
# Create .gitignore
cat > .gitignore << EOF
node_modules/
test-results/
playwright-report/
.env
*.log
EOF
# If already committed by mistake
git rm -r --cached node_modules/
git commit -m "Remove node_modules from tracking"
git push
Debugging Tips
Check connection to remote:
git remote -v
git remote show origin
View push/pull status:
git status
git log --oneline --graph --decorate --all
Test SSH connection:
ssh -T git@github.com
# Should respond: "Hi USERNAME! You've successfully authenticated..."
Force refresh remote information:
git fetch origin
git remote update
🎉 Success Checklist:
- Created remote repository on GitHub
- Initialized local Git repository
- Connected local to remote with
git remote add
- Made initial commit
- Successfully pushed to remote with
git push
- Verified files appear on GitHub
Hands-On Practice
EXERCISE
🎯 Hands-On Exercise: Create and Connect Your Test Automation Repository
Task Overview
Set up a remote repository on GitHub, connect your local test automation project to it, and push your first test files.
Prerequisites
- Git installed on your machine
- A GitHub account (free tier is sufficient)
- Basic test automation code ready (or use the starter code below)
Step-by-Step Instructions
Part 1: Create Remote Repository
-
Log into GitHub (https://github.com)
-
Create a new repository:
- Click the “+” icon in the top right → “New repository”
- Repository name:
my-first-automation-tests
- Description: “My first test automation project with remote repository”
- Select “Public” (or “Private” if you prefer)
- Do NOT initialize with README, .gitignore, or license
- Click “Create repository”
-
Copy the repository URL (should look like:
https://github.com/yourusername/my-first-automation-tests.git
)
Part 2: Set Up Local Repository
-
Create a project directory and initialize Git:
mkdir my-first-automation-tests cd my-first-automation-tests git init
-
Create test files (use starter code below or your own)
-
Configure Git (if first time):
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
Part 3: Connect and Push
-
Add files to staging:
git add .
-
Create your first commit:
git commit -m "Initial commit: Add first test suite"
-
Connect to remote repository:
git remote add origin https://github.com/yourusername/my-first-automation-tests.git
-
Verify remote connection:
git remote -v
-
Push to remote repository:
git branch -M main git push -u origin main
-
Verify on GitHub:
- Refresh your GitHub repository page
- You should see your files uploaded
Starter Code
Create these files in your project directory:
README.md
:
# My First Automation Tests
This repository contains my first test automation suite.
## Setup
- Install dependencies
- Run tests with your test runner
## Tests Included
- Basic login test
- Homepage navigation test
test_login.py
: (Python example)
def test_valid_login():
"""Test login with valid credentials"""
username = "testuser"
password = "password123"
# Add your test logic here
assert username == "testuser"
print("Login test passed!")
def test_invalid_login():
"""Test login with invalid credentials"""
username = "wronguser"
password = "wrongpass"
# Add your test logic here
assert username == "wronguser"
print("Invalid login test passed!")
.gitignore
:
# Python
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
# IDEs
.vscode/
.idea/
# Test Reports
test-results/
screenshots/
# Environment
.env
venv/
Expected Outcome
After completing this exercise, you should have:
✅ A remote repository on GitHub
✅ A local Git repository initialized
✅ Test files committed locally
✅ Remote repository connected (verified with git remote -v
)
✅ Code successfully pushed to GitHub
✅ Files visible on your GitHub repository page
Solution Verification
Run these commands to verify your setup:
# Check remote connection
git remote -v
# Should show: origin https://github.com/yourusername/my-first-automation-tests.git
# Check branch status
git branch
# Should show: * main
# Check commit history
git log --oneline
# Should show your commit message
# Check repository status
git status
# Should show: "nothing to commit, working tree clean"
Troubleshooting
Problem: git push
asks for username/password repeatedly
Solution: Set up SSH keys or use a personal access token
Problem: Permission denied error
Solution: Verify you’re pushing to your own repository and check authentication
Problem: Remote already exists error
Solution: Use git remote set-url origin <new-url>
to update
CONCLUSION
🎓 Key Takeaways
-
Remote repositories enable collaboration and backup - Services like GitHub store your code in the cloud, making it accessible from anywhere and providing automatic backup for your test automation projects.
-
The push/pull workflow is fundamental to version control -
git push
sends your local changes to the remote repository, while understanding this flow prepares you for collaborative development where you’ll also pull changes from others. -
Proper repository setup prevents future issues - Correctly connecting local and remote repositories from the start, including proper
.gitignore
configuration, saves time and prevents accidentally committing sensitive data or unnecessary files. -
Your commit history travels with your code - When you push to a remote repository, all your commits and their messages are preserved, creating a complete audit trail of your test automation development.
-
Remote repositories are the foundation for team collaboration - Once your tests are on GitHub, you’ve taken the first step toward CI/CD integration, code reviews, and collaborative test development.
🚀 Next Steps
Immediate Practice
- Push updates to your test suite as you add new tests
- Practice the commit-push workflow until it becomes second nature
- Experiment with viewing your code history on GitHub’s interface
- Try cloning your repository to a different folder to simulate team collaboration
Related Topics to Explore
- Branching and Pull Requests - Learn to create feature branches for new tests
- Collaborating with Others - Invite team members and manage permissions
.gitignore
Best Practices - Understand what to exclude from test projects- Git Workflows - Explore GitFlow or trunk-based development for test automation
- CI/CD Integration - Connect your repository to GitHub Actions or Jenkins for automated test execution
- Repository Management - Learn about repository settings, branch protection, and security
Challenge Yourself
Try creating a second repository for a different test suite and practice the entire workflow from scratch without referring to notes!