Skip to main content
Replit automatically backs up your Git repository to help you recover from issues like corrupted .git folders or lost commit history. This backup system runs in the background, so your work is protected without any extra effort.

How it works

Every Replit App maintains a secure backup of your Git repository. When Replit Agent makes changes to the code or you deploy your app, they’re automatically synced to this backup. If your local Git repository becomes corrupted or unusable, you can restore your full commit history from the backup.
The backup remote is named gitsafe-backup and is managed automatically by Replit. You don’t need to configure anything—it’s already working in the background.

Viewing your backup history

The easiest way to view your commit history is through the Git pane. Open it from the Tools section in your Workspace—it shows your full commit history including all Agent checkpoints. This works for most cases and doesn’t require any commands. If you need to inspect the gitsafe-backup remote directly, you can use the Shell:
git fetch gitsafe-backup main
git log gitsafe-backup/main
This shows your complete commit history, including all Agent checkpoints and manual commits. You can use this to verify your work is backed up or to find a specific commit to restore.

Recovering from Git issues

If you encounter Git errors or your repository becomes corrupted, start with the Git pane. It can resolve most common issues—like resetting to a previous commit or pulling from a remote—without needing Shell commands. For cases where the Git pane can’t help (such as a fully corrupted .git folder), use the Shell-based steps below.

Check if backup is available

First, verify that the backup remote exists:
git remote -v
Look for gitsafe-backup in the output. If it’s present, you can proceed with recovery.

Restore your repository

This process replaces your current .git folder with the backed-up version. Your working files remain unchanged, but your local Git history will be replaced with the backup.
1

Save your current Git configuration

Back up your Git config file in case you have custom settings:
cp .git/config .git_config_backup
2

Clone the backup repository

Create a temporary clone from the backup:
git clone --bare git://gitsafe:5418/backup.git /tmp/gitsafe-restore
3

Replace your Git folder

Move your corrupted .git folder aside and replace it with the backup:
mv .git .git_corrupted_backup
mv /tmp/gitsafe-restore/ .git
4

Restore your configuration

Copy back your Git configuration:
mv .git_config_backup .git/config
After completing these steps, run git status to verify your repository is working correctly.

Troubleshooting common issues

”fatal: repository not found” or backup remote missing

The backup system may not be enabled for older projects. Contact support if you need help recovering an older project.

Recovery didn’t include recent commits

Backups sync after each Agent commit. If you made changes but didn’t commit them, those changes won’t be in the backup. Check your working directory for any uncommitted files.

Git operations are slow or hanging

If Git operations become unresponsive, you may have a stale lock file. You can safely remove it:
rm -f .git/index.lock

Preventing data loss

While the backup system protects your Git history automatically, you can take additional steps to protect your work:
  • Commit frequently: Make small, frequent commits so your progress is continuously backed up
  • Use checkpoints: When working with Replit Agent, checkpoints automatically create commits at key milestones
  • Connect to GitHub: For critical projects, connect your app to GitHub for an additional layer of backup

Next steps

To learn more about version control on Replit: