Replit has a built-in Git pane (Tools > Git) that lets you stage, commit, push, pull, and manage branches visually. For branching and merge conflict resolution, use the Git pane for basic operations and the Shell for advanced Git commands like creating branches, switching branches, and resolving merge conflicts. AI can auto-generate commit messages. Connect to GitHub for two-way sync on the main branch.
Master Git Workflows in Replit: Branch, Commit, Push, and Merge
This tutorial covers the complete Git workflow inside Replit, from basic commits to branching strategies and merge conflict resolution. You will use both the visual Git pane for everyday operations and the Shell for advanced Git commands. This guide is for developers who want version control integrated into their Replit workflow, whether working solo or with a team.
Prerequisites
- A Replit account (any plan)
- A Replit App with code you want to version-control
- A GitHub account (optional but recommended for remote sync)
- Basic understanding of Git concepts (commit, branch, merge)
Step-by-step guide
Initialize Git and connect to GitHub
Initialize Git and connect to GitHub
Open the Git pane by clicking Tools in the left sidebar and selecting Git. If your project does not have Git initialized, Replit will prompt you to set it up. Click 'Initialize Git repository' to create a local repo. To sync with GitHub, click 'Connect to GitHub,' authorize Replit if prompted, and either create a new repository or link an existing one. Once connected, your Repl syncs bidirectionally with the GitHub repository on the main branch.
Expected result: The Git pane shows your repository status. If connected to GitHub, the remote URL appears. Unstaged changes show as modified files.
Stage and commit changes using the Git pane
Stage and commit changes using the Git pane
The Git pane shows all modified, added, and deleted files. Click the checkbox next to each file you want to include in your commit, or click the top-level checkbox to stage all changes. Enter a commit message in the text field at the top of the pane. Replit Agent can auto-generate a commit message by clicking the AI icon next to the message field. Click 'Commit' to create the commit. Your changes are now saved locally in Git but not yet pushed to GitHub.
Expected result: The commit appears in your Git history. The Git pane clears the staged files and shows a clean working state (unless there are more uncommitted changes).
Push commits to GitHub
Push commits to GitHub
After committing, click the 'Push' button in the Git pane to send your commits to GitHub. If this is the first push, Replit creates the remote branch on GitHub. Subsequent pushes add your new commits to the existing branch. If someone else has pushed changes to the same branch since your last pull, Replit will prompt you to pull first. Always pull before pushing to avoid rejected pushes.
Expected result: Your commits appear on the GitHub repository. The Git pane shows that local and remote are in sync.
Create and switch branches using Shell
Create and switch branches using Shell
While the Git pane handles basic commit and push operations, branch management is best done through Shell. Open Shell (Tools > Shell) and use standard Git commands to create and switch branches. Creating a branch lets you develop features in isolation without affecting the main codebase. When the feature is ready, you merge it back into main. This is the standard Git workflow used in professional software development.
1# Create a new branch and switch to it2git checkout -b feature/user-auth34# List all branches (local and remote)5git branch -a67# Switch to an existing branch8git checkout main910# Switch back to your feature branch11git checkout feature/user-auth1213# Push a new branch to GitHub14git push -u origin feature/user-authExpected result: You can create, list, and switch between branches. The file tree updates to show the files from the current branch.
Pull changes and resolve merge conflicts
Pull changes and resolve merge conflicts
When collaborators push changes to the same branch, you need to pull their changes before pushing yours. Click 'Pull' in the Git pane or run 'git pull origin main' in Shell. If there are merge conflicts (two people edited the same lines), Replit highlights the conflicting sections with Git's standard conflict markers (<<<<<<, =======, >>>>>>). Open each conflicted file, decide which version to keep (or combine both), remove the conflict markers, save the file, and commit the resolution.
1# Pull latest changes from GitHub2git pull origin main34# If conflicts occur, open the conflicted files.5# You will see markers like:6# <<<<<<< HEAD7# your changes here8# =======9# their changes here10# >>>>>>> origin/main1112# After resolving conflicts in the editor:13git add .14git commit -m "Resolve merge conflicts in auth module"Expected result: Conflicts are resolved, the merge commit is created, and your branch is up to date with both your changes and the remote changes.
Merge a feature branch back into main
Merge a feature branch back into main
When your feature is complete and tested, merge it back into the main branch. Switch to main, pull the latest changes, then merge your feature branch. If there are no conflicts, Git performs a fast-forward or automatic merge. Push the updated main branch to GitHub. For team projects, consider using GitHub Pull Requests instead of direct merges, which allow code review before merging. The RapidDev team recommends using Pull Requests for any project with more than one contributor.
1# Switch to main branch2git checkout main34# Pull latest changes5git pull origin main67# Merge your feature branch8git merge feature/user-auth910# Push the merged main branch11git push origin main1213# Optionally delete the feature branch14git branch -d feature/user-auth15git push origin --delete feature/user-authExpected result: The feature branch changes are now part of main. The Git log shows the merge. The feature branch can be safely deleted.
Complete working example
1#!/bin/bash2# Git Workflow Reference for Replit Shell3# Run these commands in the Shell tab (Tools > Shell)45# === INITIAL SETUP ===6# Initialize Git (if not using the Git pane)7git init8git add .9git commit -m "Initial commit"1011# Connect to GitHub remote12git remote add origin https://github.com/user/repo.git13git push -u origin main1415# === DAILY WORKFLOW ===16# Pull latest changes before starting work17git pull origin main1819# Check status of your changes20git status2122# Stage specific files23git add src/components/Auth.jsx src/utils/api.js2425# Or stage all changes26git add .2728# Commit with a descriptive message29git commit -m "Add JWT token refresh logic to auth module"3031# Push to GitHub32git push origin main3334# === BRANCHING ===35# Create and switch to a feature branch36git checkout -b feature/payment-integration3738# Work on the feature, then commit39git add .40git commit -m "Add Stripe payment form component"4142# Push the feature branch to GitHub43git push -u origin feature/payment-integration4445# Switch back to main when done46git checkout main47git pull origin main48git merge feature/payment-integration49git push origin main5051# Clean up the feature branch52git branch -d feature/payment-integration5354# === USEFUL COMMANDS ===55# View commit history56git log --oneline -105758# See what changed in a specific file59git diff src/App.jsx6061# Undo changes to a specific file (before committing)62git checkout -- src/App.jsx6364# View all branches65git branch -aCommon mistakes
Why it's a problem: Pushing directly to main without pulling first, causing rejected pushes
How to avoid: Always run 'git pull origin main' before pushing. The Git pane will also prompt you to pull if the remote is ahead.
Why it's a problem: Seeing 'Git Error UNAUTHENTICATED Failed to authenticate with the remote'
How to avoid: Go to replit.com/integrations, disconnect GitHub, and reconnect it. This refreshes the OAuth token. For private repos, you may also need a Personal Access Token stored in Secrets.
Why it's a problem: Leaving merge conflict markers (<<<<<<, =======, >>>>>>) in the code
How to avoid: Search your project files for '<<<<<<' to find unresolved conflicts. Remove all conflict markers and keep only the code you want, then commit the resolution.
Why it's a problem: Making all changes directly on main instead of using feature branches
How to avoid: Create a feature branch before starting work: 'git checkout -b feature/my-feature'. This keeps main stable and allows you to discard changes easily if needed.
Why it's a problem: Forgetting to push the new branch to GitHub before creating a Pull Request
How to avoid: After committing on a feature branch, run 'git push -u origin feature/branch-name' to create the remote branch. Then create a Pull Request on GitHub.
Best practices
- Pull from GitHub before starting new work each session to avoid merge conflicts
- Commit frequently with descriptive messages that explain why the change was made
- Use feature branches for any change that takes more than a few minutes to complete
- Name branches with prefixes (feature/, bugfix/, hotfix/) for clear organization
- Use GitHub Pull Requests for code review before merging into main on team projects
- Let Replit Agent generate commit messages for routine changes to save time
- Never force-push to main since it can destroy team members' work
- Test your code before merging feature branches back into main
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I'm working on a team project in Replit and we keep getting merge conflicts when multiple people edit the same files. Help me set up a Git branching workflow where each person works on feature branches and merges via Pull Requests. Include the Git commands for Replit Shell.
I need to create a feature branch called 'add-dashboard' and move my recent uncommitted changes to it. Help me create the branch, stage my changes, commit them, and push the branch to GitHub. Then explain how to create a Pull Request to merge it into main.
Frequently asked questions
Yes. The Git pane (Tools > Git) provides visual repository management for staging, committing, pushing, and pulling. For advanced operations like branching, merging, and conflict resolution, use Git commands in the Shell tab.
Yes. When committing via the Git pane, click the AI icon next to the commit message field. Agent analyzes your staged changes and generates a descriptive commit message automatically.
Go to replit.com/integrations and re-authorize your GitHub connection. This is the most common Git error and is caused by an expired OAuth token. If the error persists, try disconnecting and reconnecting GitHub.
The Git pane supports basic branch operations on some plans, but for full branch management (create, switch, merge, delete), use Git commands in the Shell tab. The Shell provides the complete Git CLI.
The default two-way sync works on the main branch. For other branches, you push and pull manually using Git commands in Shell. Branch switching support is available but may require the Labs feature flag in Settings.
When a pull or merge creates conflicts, Replit marks conflicted files with Git's standard markers (<<<<<<, =======, >>>>>>). Open each file, choose which version to keep, remove the markers, save, stage the files, and commit the resolution.
Yes. The RapidDev engineering team can help establish branching strategies, code review workflows, and CI/CD pipelines for teams building on Replit. This includes setting up GitHub integration, Pull Request templates, and automated testing.
Replit's built-in Git pane only integrates with GitHub natively. For GitLab or Bitbucket, use Git commands in Shell to push and pull manually. The full Git CLI is available, including the 'glab' command for GitLab.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation