Git Quick Start

Git is a popular Version Control System or VCS like SvN and TFS for managing projects and tracking changes in computer files.
Look at the chart above, the interest of git is in perpetual growth since 2004.

In this topic I will explain bravely basic Git commands.

To install Git go here git.

Create a new folder on your disk and open Git Batch console like this :

Init a Git Repository > git init

Type git init to create a local git repository or reinitialize an existing one. A .git directory will be created, it contains all necessary resources to manage the git repository.

Configure User and Email with Git Bash > git config

Type git config to set the configuration like and These variables are used to determine the author or the committer of changes.

Add File to the Cache of a Git Repository > git add fileName

Type git add to add a file to the cache or staging area called index. This index is located here .git/index.

Check Status of Working Tree > git status

Type git status to show working tree. It displays differences between staging and repository (HEAD).

Open Git Gui > git gui

Type git gui to launch the graphical git interface

Remove File From the Cache > git rm --cached fileName

Type git rm to remove files from the cache (index).

Add Files to the Cache > git add . (or git add *)

Type git add ./* to add files to the cache or staging area (index).

Restore Working Tree Files > git checkout

Type git checkout to restore files to match with the version in the index.

Commit the File > git commit -m ‘commit message’

Type git commit to record changes to the repository (HEAD)

Use .gitignore File

.gitignore specifies files to be ignored by git.

Open .gitignore and Add Files to Ignore

Create Branch > git branch branchName

Type git branch to create a new branch.

Switch to a Branch > git checkout branchName

type git checkout to switch to another branch

List Branches > git branch -- list

Type git branch --list to display all branches

Merge Branches > git merge branchName

type git merge to incorporate changes from the named branch to the current branch.

A--B--C--D---F/F/G- --> master
\ /
E--F--G --> Dev

Push the Repository to GitHub > git remote/push

Type git remote add to map local repository with remote repository

Push Changes to GitHub > git push

Type git push to update the remote repository from the local repository.

Update Your Local Repository From GitHub > git pull

Type git pull to fetch from the remote repository and integrate to the local repository

Clone Repository > git clone

Type git clone to clone a repository into a new created directory.

For more details see the git official website here.

Enjoy :)



Senior Full Stack .Net / Angular Developer, Cloud & Azure DevOps, Carrier Manager, Husband, and Father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdelmajid BACO

Senior Full Stack .Net / Angular Developer, Cloud & Azure DevOps, Carrier Manager, Husband, and Father.