sabrams
sabrams

Reputation: 1128

How to git pull without overwriting database data

I have a new project that I have cloned to a server. There is no need for full deployment since the server and my workstation are in the same room. I want to be able to make changes to my project, then push them to git, and pull them down to the live version on the server, but I don't want any of the data being inputted into the database to get overwritten.

Right now I am just using:

 git push origin master

abd on the workstation:

 git pull origin master

on the live server.

If I have the server set up as the "production environment" and the workstation using the "development environment" of the database (SQLite3), will I be overwriting any newly inputted data every time I pull from git? What git commands should I be using in this case?

Upvotes: 1

Views: 935

Answers (1)

Moritz
Moritz

Reputation: 4781

You can specify that the file should be ignored in your gitignore. In your top-level directory, there should be a file named .gitignore (it may be hidden in your file browser.) Open that file and add path/to/<mydb>.db, clearly changing the path and name as appropriate.

Now, the file shouldn't be included in new commits. BUT, if you have already pushed it on previous commits, it will already be tracked by git, so the gitignore by itself probably won't work. So you might also have to run git rm path/to/<mydb>.db in your terminal to remove the file from the index.

Upvotes: 2

Related Questions