Your First Git Repository

Your First Git Repository

In this tutorial we will be creating new repository and run basic commands

 

Create new repository and call it "dotsway"

Create a folder and initializing it.

mkdir dotsway

cd dotsway

git init

Now if you run ls -la you will notice a hidden folder called "git" this folder which will contain all tracking info.

Create new code file.

vi code.py

Check GIT Status

git status

Now you will notice that a file is added but not under the version control system.

Add the file to repository

git add code.py

Now the file is adding to staging area but not committed to repository.

Your First Commit.

First you need to create README.MD file, MD stands for markdown which is a way of formatting the file. Add whatever information to that file and then save and exit.

vi README.MD

Second you need to create a hidden file called gitignore and in this file you will list folders and/or files which you don't want to be under version control (ex.: swap files, temp files or data).

vi .gitignore

*.swp "for example"

Save and exit.

 

Commit Changes to Repository

git commit -m "My first commit comment note"

 

 

Using Git Diff

If you use below command you will check the difference between the files and staging "the files added with git add"

Git diff

If you use git diff and HEAD you will get the difference between files and repo server.

git diff head

 

Viewing History

git log

View log for certain file

git log file-name.py

 


Subscribe to
for video tutorials updates