GIT Tutorial for Beginners

GIT is a distributed version control system. It helps in tracking changes in an application code, config folders over time across different users in different machines who are working together on a same project for same application development

Installing GIT

From official website or thru your company software installation system you can install git in your machine

After installation is done, open gitbash command line interface in your machine and check version with this command. If it gives version details, it means installation is successful

$git – -version

Set Config Value

$git config – -global “John Walter”

$git config – -global [email protected]

$git config – -list

These variable gives idea about user who is checking code in and out in the repository.

GIT Help

$ git help config

$ git config – -help

$git add – -help

Initialize a git repository which is locally

$git init

Try git status before commit

$git status

This will show list of files along with the ones which are not required to be committed. To ignore such files you can run a command

$ touch .gitignore

$vi .gitignore

Put the files you don’t want to commit

Then run

$ git status

Add files to staging area

$git add -A

$git status

$git commit

This will commit these changes in staging area to the repository

Remove files from a staging area

$git reset

$git status

$git commit “ tkt-2010: first commit”

$git log

Shows details of the commit

Cloning a remote repository

$git clone <remote repo url> <target local location>

View remote repository

$git remote -v

$git branch -a

After making the changes locally, commit these changes locally and then push it to the remote repository

$ git diff

$git status

$git add -A

$git status

$git commit -m “ticket no:24: this is for test”

$git pull origin master

To pull any changes to local repo that has been made in remote repository in between while you were working locally.

If no changes present, then only push

$git push origin master

Next Page>>