DEV Community

Cover image for Getting started with Git and Github
john mbugua
john mbugua

Posted on

Getting started with Git and Github

Intro

version control

Version control is also known as revision control /source control is a class of systems responsible for managing changes to your files.

Types of version control system

  1. Centralize version control systems
  2. Distributed version control systems

Centralized version control system

CVCS have only one central repository. Repository is basically a server which all the file and history are stored. The machine can access the repository via LAN and WAN.

Example of CVCS:

  1. Concurrent version system (CVS)

  2. Subversion (SVN)

cvcs

Distributed version control system

DVCS don't require a central server that contain repository. Every user has its own repository called local repository.

Example of DVCS:

  1. GIT
  2. Bit-keeper

dvcs

What is git ?

GIT is a decentralized version control system used to keep changes of your file.

GIT was developed by Linus Torvalds in 2005 for efficient code management and version control of their project. Understanding basic commands of git could help you in storing your projects in your local repository and pushing them into your remote repository.

Git installation

.Windows

Download git for windows

.Mac

Download git for mac

.Linux (Debian)

$sudo apt-get install git

Git commands

The following are basics commands of git.

git config

This command is used to set user configuration such as user-name and user-email as shown below:

git config

git init

This is one of the common git command you will be using. Its used to initialize local git repository.

git init

git add

The command git add is used to add the file into local repository for example below the .index will be added to local repository:

git add

git status

This git status command is used to check status of working tree. Below you see three file which are untracked:

git status

git commit

The git commit command is used to commit in the staging area. The committed changes will now go to remote repository. Example:

git commit

git push

Once the files have been committed the git push command is used to push the files to remote repositories:

git push

git pull

The command git pull is used to fetch/merge content in remote repository into local repository:

git pull

git clone

This command is used to download existing git repository into your local repository. For example below the git clone command will download the files from existing remote repository to local repository(basics of git):

git clone

git rm

The command git rm will delete or remove the file from repository: Below we can see the file .index removed:

git rm

git branch

This command is used to create a new branch. Example git branch will create new branch called myapp:

git branch

git checkout

This command help you to navigate from one branch to another. Example we used git checkout to navigate from master branch to myapp branch:

git checkout

git merge

The git merge is used to integrate two branches together. It will merge one branch to another active branch. Below we have merge myapp to master branch:

git merge

Top comments (0)