简体   繁体   中英

db/development.sqlite3 merge conflict in Rails 4

I ran into a merge conflict in file db/development.sqlite3 .

warning: Cannot merge binary files: db/development.sqlite3 (HEAD vs. nest-questions)
Auto-merging db/development.sqlite3
CONFLICT (content): Merge conflict in db/development.sqlite3

Normally I would open file (in Cloud9 IDE), manually edit out the conflict, and done.

But I cannot read anything in this file - it just looks like gibberish.

The app is in development. Can i just wipe out the file, then run rake db:reset , or will cause issues? I've never manually modified this file before.

Has anyone resolved a conflict in db/development.sqlite3 before and can advise?

You won't be able to resolve a merge of db/development.sqlite3 by hand. It's a binary format of the SQLite database that Rails is using behind the scenes when you are using rails console , rails server or an equivalent app server.

The typical approach is to make sure that these .sqlite3 files are ignored by git (since you don't usually wish to persist your database to your source code repository).

To resolve:

git rm db/*.sqlite3
git commit -m "Removing SQLite files from git"
rm .gitignore
wget https://raw.githubusercontent.com/github/gitignore/master/Rails.gitignore
mv Rails.gitignore .gitignore
git add .gitignore
git commit -m "Ignoring files that Rails recommends"

The sqlite files and many others will be ignored by this technique. Note that if the files in question are already in your repository, you'll be prompted to work with them as usual. You'll need to remove them from the repo using git rm before these changes take effect.

You can wipe out the file with db:reset, etc. as you mention above, but the problem will recur until you take the above (or similar) steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM