Sitemap

Git Quick Start

4 min readNov 30, 2019

--

Press enter or click to view image in full size

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.

Evolution of Git popularity 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 :

Press enter or click to view image in full size
Git Bash

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.

Press enter or click to view image in full size
init a git repository

Configure User and Email with Git Bash > git config

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

Press enter or click to view image in full size
configure Git Batsh

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.

Press enter or click to view image in full size
Add file to the cache or staging

Check Status of Working Tree > git status

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

Press enter or click to view image in full size
check status

Open Git Gui > git gui

Type git gui to launch the graphical git interface

Press enter or click to view image in full size
Git Gui

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

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

Press enter or click to view image in full size
remove file from the cache

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

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

Press enter or click to view image in full size
Add files to the cache
Press enter or click to view image in full size
Gui after adding files

Restore Working Tree Files > git checkout

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

Press enter or click to view image in full size
remove file
Press enter or click to view image in full size
restore file

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

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

Press enter or click to view image in full size
commit files

Use .gitignore File

.gitignore specifies files to be ignored by git.

Press enter or click to view image in full size
using .gitignore file

Open .gitignore and Add Files to Ignore

Press enter or click to view image in full size

Create Branch > git branch branchName

Type git branch to create a new branch.

Press enter or click to view image in full size
create branch

Switch to a Branch > git checkout branchName

type git checkout to switch to another branch

Press enter or click to view image in full size
switch branch

List Branches > git branch -- list

Type git branch --list to display all branches

Press enter or click to view image in full size
list 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
Press enter or click to view image in full size
merge branches

Push the Repository to GitHub > git remote/push

Type git remote add to map local repository with remote repository

Press enter or click to view image in full size
push to gitHub

Push Changes to GitHub > git push

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

Press enter or click to view image in full size
push changes to gitHub

Update Your Local Repository From GitHub > git pull

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

Press enter or click to view image in full size
pull changes from gitHub

Clone Repository > git clone

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

Press enter or click to view image in full size
Cloning repository

For more details see the git official website here.

Enjoy :)

--

--

Abdelmajid BACO
Abdelmajid BACO

Written by Abdelmajid BACO

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