Git Basics in Minutes

Git

Git for Windows

 

Git is a free and open source distributed version control system.

Git was created as a command line tool.

Over the last few years, we have seen the GUI of git.

Popular git GUI’s are,

  • Git Desktop
  • Git Karen
  • SourceTree

Below is the link where you can find all the GUI clients,

 

 https://git-scm.com/downloads/guis

Installation of Git

 

Git Bash gives the Git command line experience for Windows machines.

To install Git Bash, Download Git for Windows,

You need to go to,

https://git-scm.com/download/win

Git Version

After the installation, to check the git version use the below command,

git –version

Git Configuring

You do not need to register for an account, but you will need to provide:

  • Your name.
  • Your email.

If using GUI, you should get a prompt for your name and email for the first time.

To configure the name and email address below are the commands

git config –global user.name “shoaib.shaikh” > git config –global user.email “shoaib@qualitytestinghub.com”

Git Configuration Commands

 

Git Repository

A Git Repo is a workspace that tracks and manages the files within a folder.

Git Init and Git Status

Git init is used to create a new git repository. Git initialize is required before we do anything related to git.

This is a one-time activity.

git init

Git Status gives the current status of a git repository and its contents.

git status

.git folder

 

A .git folder contains all the history of your original data files, along with all the log messages, author information, dates, and other information you will need to rebuild any version of the project.

By deleting the .git folder, Git will lose the information it stores, and the directory will no longer act as a repository for Git.

Git tracks a directory and all nested subdirectories.

Do not Init a repo inside of a repo. Before using git init, use git status to verify that you are not currently inside a repo.

Below is an example with a folder with already git init done and git init not yet performed in a folder.

Git init and wo Init

Git Commit

A commit is a checkpoint. You save the save before you do a commit.

You can make changes or add modify or delete a file and group changes together into a single commit.

It’s a snapshot of changes in our repository, at a specific point in time.

In the future, we all be able to go back to earlier commits, undo commits, and merge commits and you can do lots of stuff.

Basic Git Workflow

Work on Stuffs (Working directory) : in the working directory (Add, Edit, and delete files, etc)

Add Changes (Staging area): group changes together for committing.

Commit: Commit changes that were added.

Changes go inside the repository.

 

Git Add

The git add command is used to add the files into the staging that can be grouped and then we can commit those.

Below is the syntax,

// To add all files in stage use

git add 

// To add a specific file

git add file

// You can add multiple files

git add file1 file2

 

Git Commit

  Committing changes from the staging area is done using the git commit command.  

While making a commit, we need to provide a commit message. (Summary of the changes and work snapshotted in the commit).

Below is the syntax,

git commit -m “message of commit”

SummaryGit_Basic Summary

Leave a Comment

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