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 :

Tutorial series on creating a basic Blog Application using Django

In the series previously we have covered:

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.

Installing Git

For Windows:

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 :

git status

Output :

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"

Output :

[...]
 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 :

Leave a Reply

Your email address will not be published. Required fields are marked *