Git Tutorial

What is GIT?

Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files.

 As a distributed revision control system, it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

Installing GIT

Click here to install Git For Windows

Git Setup

After you have downloaded the git its time to set up the user , git comes with the tool called as git config , it lets you control your git account

git congif --global "Saad Masuri" (Press Enter)
git config --global (Press Enter)

Getting Help

You can also get help from git there are different ways to get the manual page for git help. Write below line of code in command line.

git --help (Press enter)
git help config (Press Enter)

Git Repository for already existing project

If you are already having an project files , you have them to track on git then just navigate to your project path and use below command

git init (Press Enter)

This will create sub directory named .git(hidden folder) that contains all necessary files of your project

Cloning Existing Repository

To clone existing repository on git to your system , type below code in command line

git clone url
#Here url will be the link of the repository you want to clone in your system

Checking commit History

You can also check the commit history with the simple command like

git log (Press Enter)

Adding file to Repository

Use git add file to add file to the repository: git add index.html

If you want to add all files of your system to repository then use (.dot) after add.

git add . (Press Enter)

Commit the code

In previous step you have added the files , but it is not updated into your git repository yet , it is in your local system only, to add this file to repository you have to use below command after add command.

git commit -m "Initial contents"

To commit data directly to remote repository without going into staging stage use below command

git commit -am "Initial commit directly to remote repo"

Checking Status

After you commit the addition of the new file into the repository, git status indicates
that there are no outstanding.

git status (Press Enter)

Git also takes the time to tell you that your working directory is clean, meaning the working directory has no unknown or modified files that differ from what is in the repository.

Author: Saad Mansuri

Leave a Reply

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