Setting Up Git, GitHub, and Version Control for Automation Projects

🧠 Learning Objectives:

By the end of this lesson, learners will:

  • Understand the importance of version control in automation projects
  • Install and configure Git locally
  • Create and link a GitHub repository to their framework
  • Learn basic Git commands for daily use
  • Understand best practices for collaborative test automation with Git

📌 1. Why Use Version Control in Test Automation?
Without GitWith Git
Manual file backupsVersion history of every test case
No way to collaborateMultiple testers can work in parallel
No rollback on failuresEasily revert changes or bugs
Risk of overwriting filesGit tracks and resolves merge conflicts
Difficult CI/CD integrationSeamless with GitHub Actions, Jenkins

In test automation, especially when working with teams or CI/CD, Git isn’t optional — it’s essential.


🧰 2. Install Git (if not already installed)
🔹 Download Git:
🔹 Verify Installation:

git --version

Expected Output:

git version 2.x.x


👤 3. Configure Git Locally

Set your name and email to associate with your commits:

git config --global user.name "Your Name"

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

Optional: enable colored output and default editor

git config --global color.ui auto

git config --global core.editor "code --wait" # if using VS Code


🗂️ 4. Initialize Git in Your Automation Project

Let’s assume you’ve created your framework folder:

cd ~/projects/salesforce-karate-framework

git init

This creates a hidden .git folder that starts tracking version history.

Create a .gitignore file to avoid committing IDE or test output files:

# .gitignore

.idea/

target/

*.log

*.class

.DS_Store

.env


☁️ 5. Create a GitHub Repository
🔹 Steps:
  1. Go to https://github.com
  2. Click New Repository
  3. Name it: salesforce-karate-framework
  4. Set visibility: Public or Private
  5. Don’t initialize with README or .gitignore (we already have them)

🔗 6. Connect Local Project to GitHub

In your terminal:

git remote add origin https://github.com/yourusername/salesforce-karate-framework.git

git add .

git commit -m "Initial commit: setup project structure"

git branch -M main

git push -u origin main

🎉 Your project is now under version control and connected to GitHub.


🧪 7. Daily Git Commands for Test Automation Projects
CommandWhat It Does
git statusShows current changes
git add .Stages all changes
git commit -m "message"Saves a snapshot with a message
git pushSends commits to GitHub
git pullUpdates local project from GitHub
git logShows commit history
git checkout -b new-testCreates a new branch for a test case

🌱 8. Best Practices for Automation Projects
  • 💡 One branch = one feature or test case
  • Write clear commit messages (e.g., add login.feature for Salesforce UI)
  • 🔁 Pull before you push to avoid merge issues
  • 🧪 Use Git to track test data, config files, and metadata scripts
  • 🛠️ Integrate with GitHub Actions (later lessons) to run tests on push/merge

🎓 Learner Exercise:

✅ Create a GitHub repository and push your current automation project
📸 Take a screenshot of your repo and git log output


📌 Recap:
TaskStatus
Git installed
Configured name/email
Project tracked with Git
Pushed to GitHub

About the author 

PoojaBharat

Our mission on this planet is to help you in leaving the past behind and creating the future with you, so you can live happily in the present and embark on the journey of fulfilling life.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
Subscribe to get the latest updates
>