sabrams
sabrams

Reputation: 1128

How do I git pull without overwriting a single file

I'm very new to git. I use

git push origin master

to push my app, and

git pull origin master

to pull it down. I do not want to overwrite one single file: db/development.sqlite3, because it has all of the data that has been inputted by users on my live app. However, when I push changes from my developing computer, then go to pull them to the live server, I get an error saying that I cannot pull changes because that file is different now and would be overwritten by the merge. It says please commit your changes or stash them before you can merge. But I just want git to not pull and overwrite that file at all.

Upvotes: 0

Views: 2477

Answers (2)

Schleis
Schleis

Reputation: 43700

Stop tracking the file in your repo.

git rm --cached db/development.sqlite3

This will remove it from your repo but retain the current state of the file. Then you should create a .gitignore file that has this file listed in it.

Upvotes: 3

locke14
locke14

Reputation: 1375

You could make a branch and commit the changes of that file to it. Then do a git pull origin master. You can merge the branch later on..

Upvotes: 0

Related Questions