Search code examples
version-controllocalgit-submodulesgit-subtreedjango-apps

How to manage Django Project and its modules with git?


I've been looking for a solution how to manage my project with git for quite some time now. I want to have one instance as the main repo for connecting the entire project. Each app should be its own git instance. During my search I found both git submodule and git subtree. For both tools I found an instruction how to insert an existing reppo. However, I am interested in how to proceed from the beginning. I mean here from the command

$ django-admin startproject myproject
Where do I enter the git init? When I create a new app

$ django-admin startapp new-app
and how do I use this as subtree/submodule?

Until now I have always found instructions that refer to a remote repo. Is this always necessary? I am not sure if I want to publish every Django app on Github. But I want a version control system just for me. Is this possible?

I have to say that so far it has been enough to manage my "projects" locally. Now I want to work together with others and I don't want to install the whole Django Project locally but only provide me with single functions or modules.

It would be a great help if you could explain to me how that works.

TL;DR
How to manage (start and expand) a Django Project with git. The apps should be their own git repos.


Solution

  • The purpose of submodules is to allow you to graft an existing repo/library into your git. Rarely do you want to do this. Instead you want to use PIP tools to install your libraries as part of library management.

    This is essentially a git question. If you don't have a remote repository, you can still use git. With that said, the reason you want a remote repository is so that you can collaborate with others, and have a stored version of the code separate from your workstation.

    There are services that let you have private repos even without a paid account. Bitbucket is the most well known of these services and is comparable to Github in most ways.