What is git?

It is a distributed source control system. Due to the distributed in nature it can scale massively.Creator of git Linus Torvalds  want to create a version control system that could handle the requirement of linux kernel project. Today the linux kernel project 50milion lines of code(LOC) with 1200 worldwide developer contributing to the project. Another key benefits of git most of the operations are local there are few commands that require network connection otherwise you can completely work disconnected. So it is very fast. It is free and open source. Git have very active community and there are many resources available onine. Easy to find developers who have already have experience in git. Because off all these factor git is most popular VCS. Git de facto standard means it enjoy wided option for integration into other tool used by developer community including text editor, bug tracking system and build server.

Key Concepts:

  • Repository contains files, history, config managed by Git.
  • Three state of local git
    • Working directory (which holds all the project/application file, it may or may not me handle by git. Normally whiten a working directory there is a hidden folder /.git that contain the actual git repository, it manages the git commit history i.e all the changes that are finalized in permanently part of git repository )
    • Staging area- pre-commit holding area (Often referred as git index, i.e is a holding area queuing of changes  for the next commit since fie in the staging area not commited yet, you can in and out file from staging area without impacting git repository )
    • Commit – Git repository (history)
  • Remote repository (GitHub)
  • Master branch: They are time line contents changes. In git branches contents commit , when we start git provide us the default branch called master branch.

Git Installation:

Git for windows

git download.png

Go with default option click on next -> next click on finish.After installation open git bash and check version.

chk version after installation

Setup Project

setup project

Git Configuration User Name Email

set username

Conform the settings

chk list

Create repository in github

create repository

Clone a repository (copy from GitHub to your system)

Go inside the repository and copy the path

copy path

Then go to git bash

clon project

By this git will create a clone of repository to a local system. Conform clone have been made.

conform cloning

Git status: It will display the working tree status. default it will have master branch. Used to check any changes in local repository and remote repository.

git status

First Commit:Create a file and add it to git.

create file

Once the file created check the git status

untrack file.png

It shows file is present in working directory but not yet added to git.

Will add the file to staging area and check the status.

add to staging

After that will commit to git from staging area.

git commit

Publishing to GitHub(Publishing our changes)

After the commit new file in local repository, commit is a local command still file is not in github.

git push

origin refers GitHub copy of our repository. master is the name of the branch to push since the only branch we have. Now if you will check in GitHub file will be there.

fill add