Brandon
Brandon

Reputation: 175

How to not overwrite database information in a Git merge

I have a CRUD app that will be used to track trucking appointments. I'm ready to deploy the app, but I'm worried about merging a future branch into the main branch without overwriting the existing information in the database. How can I use CLI git commands to avoid overwriting the data?

These are the general steps I've been using to merge a branch that I've made edits to into the main branch:

>git checkout main
>git merge <branch_name>
>git branch -d <branch_name>
>git push origin --delete <branch_name>

github files github files in CLI

Upvotes: 1

Views: 176

Answers (3)

VonC
VonC

Reputation: 1323135

Note: putting test.db within my .gitignore configuration file is not enough.

If it was tracked, you would need to "untrack" it with:

git rm --cached -- test.db

Then you can check your new .gitignore rule is effective with:

git check-ignore -v -- test.db

Upvotes: 1

Brandon
Brandon

Reputation: 175

I included test.db within my .gitignore configuration file.

Upvotes: 0

J Claire
J Claire

Reputation: 11

Production data should not be stored in the same directory as code for many reasons other than worrying that git will overwrite your data. For one, your software shouldn't have permissions to modify itself, even though it needs permissions to overwrite its database. You'll need to search/ask how best to package Python and set up a service on the operating system you'll be using.

git has some safety features that protect untracked files. checkout and switch won't clobber them. But clean is designed to delete untracked files. Worse: reset --hard will overwrite untracked files without warning. Do not put important data in a working directory unless it's part of the project.

Upvotes: 1

Related Questions