Introduction to Git and creating your Git repository
In this tutorial we are going to learn about what Git is, what its features and uses are, and finally how to use it to create your own Git Repository.
Create Blog Web Application using Django – Create Git Repository
This post uses the Django code from the tutorial series on Creating a blog application. You can have a look at the series :
In the series previously we have covered:
- Introduction to Django Framework and How to install it? (Part I)
- How to create your Django project and modify its settings. (Part II)
- Setting up Database for Django project and running Server(Part III)
- Creating Django Application and Introduction to Django Models(Part IV)
What is Git?
Git is a platform to register changes in the source code while alongside maintaining all the previous code. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files.
Using Git, we can manage the different versions of the same source code and can also undo some changes using code from the previous version.
Download the .exe file from https://git-scm.com/
When it asks for code editor; choose Nano
and as for the PATH environment; choose “Use Git and optional Unix tools from the Windows Command Prompt”. Restart the Command Prompt
For Ubuntu or Debian based Distributions :
Run the following command in the Terminal
sudo apt install git
For Fedora :
Run the given command,
sudo dnf install git
Starting a Git Repository
Git stores this information in a data structure called a repository.
A git repository contains, among other things, the following:
- A set of commit objects.
- A set of references to commit objects, called heads.
To start a Git Repository, run the following commands:
git init git config --global user.name "Sample_Username" git config --global user.email [email protected]
( Now for those who came from Blog Application tutorial, open up your text editor and create a file named .gitignore and add the following code in it :
*.pyc *~ __pycache__ codespeedy_venv db.sqlite3 /static .DS_Store
and save it in the same directory containing your Project files. )
Other, users create a .gitignore file according to your project.
Now, run the following commands :
On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore blog1/ manage.py site1/ requirements.txt nothing added to commit but untracked files present (use "git add" to track)
git add --all . git commit -m "My first commit"
[...] 13 files changed, 200 insertions(+) create mode 100644 .gitignore [...] create mode 100644 site1/wsgi.py
That’s it! You have successfully created your Git repository.
Feel free to ask any query in the comments section below
Check out some other posts :