1

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

isherwood
  • 58,414
  • 16
  • 114
  • 157
Brandon
  • 117
  • 7
  • 5
    Can you explain a bit more about the problem you're worried about? A database would normally be completely separate from the code stored in a git repository, so there would be no reason to expect a branch merge to make any difference to it. – IMSoP Oct 10 '22 at 12:54
  • I have a `test.db` file located in my project folder that stores the app data. I assumed that this file would be included in the git repository. Is that not the case? – Brandon Oct 10 '22 at 12:59
  • 3
    Have a read of [How can I put a database under git (version control)?](https://stackoverflow.com/questions/846659/how-can-i-put-a-database-under-git-version-control), but I would recommend not putting it into git – evolutionxbox Oct 10 '22 at 13:01
  • Is the `test.db` file location correct? And I just need to remove it from the git repository? – Brandon Oct 10 '22 at 13:08

3 Answers3

1

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.

J Claire
  • 11
  • 1
1

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

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

Brandon
  • 117
  • 7
  • 2
    .gitignore is not a directory; it's a configuration file where you list the files you want to ignore – IMSoP Oct 10 '22 at 14:29