jonnny
By:
jonnny

Configure Git for a Django project on ubuntu 16.04

January 14, 2017 619 views
Django Git Deployment Ubuntu 16.04

The last piece in my server config is to set up git to allow for automatic deployment from my dev workspace to my live workspace. I've not used git with Django before, I work alone and only use git to keep a track of my changes in code and filezilla files over from dev -> live. So I'm just trying to make sure my knowledge is right before I do this. I have read this: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

My Django set up, has been taken from @jellingwood brilliant tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

So the path to my django project would be?

/home/sammy/myproject

and within myproject would be the directories:

  • static
  • myproject
  • virtualenv

From the git guide I mentioned, they use the following fictitious paths

Your server live directory: /var/www/domain.com (I assume mine should be:/home/sammy/myproject)?

Your server repository: /var/repo/site.git (Assume this is the path to my github repo OR is it am I creating a repo within my own server)?

cd /home/sammy/myproject
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare

Because I already have stuff in myproject should it just be git init (and drop the --bare)?

When it comes to local machine set up, the guide says:

git remote add live ssh://user@mydomain.com/var/repo/site.git

I'm thinking that this is to a repo within my own server as I type this now - If so, as a follow up question: How would I make it where it also pushed to a private github repo, so I could see and track the changes over time, or is there a way to still do this following the current guide?

Could someone clarify the process with regards to Django and not breaking the Django setup/virualenvs etc?

1 comment
  • @jonnny Hey, have you found the answer on your question? There is the same thing that is confusing me with django project and git, namely what should be the paths.

Be the first one to answer this question.