Set up Version Control
If you are serious about developing a proper web application, you simply need version control. Not even sure what version control is? Well you have come to the right place.
Last updated
If you are serious about developing a proper web application, you simply need version control. Not even sure what version control is? Well you have come to the right place.
Last updated
Git is the version control system of choice for the majority of developers. It allows code changes to be committed and tracked as well as conflicts to be managed and merged. And believe us, it is simply a must-have if you are planning on developing a Django application. If used correctly, it will provide you full transparency of all your code changes and the confidence to make radical changes considering you'll always have a safe way to revert to previously working versions.
There are of course plenty of options out there to get yourself set up with git. However, GitHub is our preferred provider, as they offer a clean visual interface with a wide range of functions (beyond basic git) to help manage your project. So to get started, head over to GitHub and create yourself a free account.
Git uses repositories to store code. You can think of a repository as a folder, and typically you make one per project to store all associated project code. So, start off by using the GitHub interface to find your current list of repositories (you shouldn't have any if this is a new account), and then use the create button to create a new one.
Next, considering we will be committing DjangoMango code which cannot be openly shared as per its use licence, you will need to select 'Private' rather than 'Public' for the repository type. This will ensure that only you, and those you designate as project contributors will be able to view the code you commit.
You next have some possible options of initializing your repository with a README.md, adding a .gitinore or adding a license. We can go ahead and leave all of these options blank.
Finish up by selecting the 'Create repository' button.
Now that you have your repository hosted on GitHub, it's time to clone that repository to your development environment. To do so, open your repository via GitHub and find the 'Code' drop-down button. When you click this drop-down you should be presented with a GitHub address to your repository. Copy that address to your clipboard.
Next, open the terminal on your Unix-based OS and confirm that you have git installed by running:
If you don't have git, never fear, you can simply install using the correct instructions for your OS.
Once you have confirmed git is installed. Go ahead and browse to the location where you want to clone your repository folder. Then, run the 'git clone' command to clone your repository, but make sure you substitute the repository address copied earlier from GitHub:
If everything worked, you should have cloned your empty repository folder to your current location.
You should already know how to download and unzip your project archive from your Member Portal as per the Getting Started instructions. So let's go ahead and place those files in our cloned repository folder. We recommend you place the files directly in your repository folder rather than in a sub folder, as it will avoid setup issues later.
So looking in your repository folder, and you should see something similar to the below:
Next, open your terminal back up. Confirm that the terminal is still pointing at your repository folder, which now contains all of your project files, and then run the following commands in order to commit and push the files to your repository:
If everything goes well, you should be able to access your repository via GitHub and see your committed project files.
From here, we recommend you start getting familiar with basic git commands. In particular:
git clone /path/to/your/repository
- clone a repository to your environment
git add <filename> / git add .
- add a particular file or all files to the git tracker
git commit --all
- commit any modified files or new files added to the tracker
git push
- push your commit to the repository
git stash
- store your uncommitted changes and revert to last commit
That should be more than enough to get you going.