DOCS LLMs

Migrating Existing Project

Here's the simplest, most reliable way to "adopt" RailsFast into an existing Rails project and start getting updates.

Goal

  • Link your project’s history to the RailsFast template so future updates are just normal git merges.
  • Keep your current code as-is during adoption.
  • Preserve secrets/config with merge guards.

One-time adoption (manual)

  1. Prep
  • Commit or stash everything: git status should be clean.
  • Create a safety branch: git checkout -b adopt-railsfast-backup
  1. Add RailsFast as a remote
git remote add railsfast [email protected]:railsfast/railsfast-base.git
git fetch railsfast --prune
  1. Establish a baseline relationship (don’t change your files)
  • This records the template as a merge parent without altering your tree.
git merge --allow-unrelated-histories -s ours --no-ff -m "Adopt RailsFast upstream at baseline" railsfast/main
  • Result: histories are now related. Future git merge railsfast/main will bring only changes made in the template since this baseline.
  1. Add merge guards so protected files always keep your local version
  • If you already have .gitattributes, add lines like:
echo '# RailsFast: Preserve local configuration during template merges' >> .gitattributes
echo 'Dockerfile merge=ours' >> .gitattributes
echo '.kamal/secrets merge=ours' >> .gitattributes
echo 'app/views/pwa/manifest.json.erb merge=ours' >> .gitattributes
echo 'config/application.rb merge=ours' >> .gitattributes
echo 'config/database.yml merge=ours' >> .gitattributes
echo 'config/deploy.yml merge=ours' >> .gitattributes
echo 'config/railsfast.yml merge=ours' >> .gitattributes
echo 'config/credentials.yml.enc merge=ours' >> .gitattributes
echo 'config/master.key merge=ours' >> .gitattributes
echo 'config/db.key merge=ours' >> .gitattributes
  • Configure the merge driver + rerere:
git config merge.ours.driver true
git config rerere.enabled true
git add .gitattributes
git commit -m "Configure RailsFast merge guards"
  1. (Optional) Record metadata for RailsFast CLI status
  • If your repo already includes bin/railsfast, you can record the baseline and remote without changing your app:
bin/railsfast init --yes --skip-rename --skip-setup
  • This writes .railsfast/config.json and remembers the remote/branch/baseline. If you don’t have the scripts yet, you can skip this step.

Verifications

  • Check relation and baseline:
git log --oneline --graph --decorate --all | head -n 50
  • See behind count:
git rev-list --count HEAD..railsfast/main