Вы находитесь на странице: 1из 28

GIT -Essentials

- VEERESH H R
About Git

Created by Linus Torvalds,creator of Linux, in 2005

Linus Benedict Torvalds is a Finnish-American software


engineer who is the creator and, historically, the principal
developer of the Linux kernel, which is the kernel for
Linux operating systems and other operating systems
such as Android and Chrome OS.

● Came out of Linux development community


● Designed to do version control on Linux kernel.

Git is a free and open source distributed or decentralized


version control system.
Reasons Everyone Use GIT

With distributed nature, git can scale massively.

Open Source , free , very fast and huge developer community.

It is designed to handle everything from small to very large projects with speed and
efficiency.
What is Version Control?
You can think of a version control system (short: "VCS") as a kind of "database". It lets you save a
snapshot of your complete project at any time you want. When you later take a look at an older
snapshot (let's start calling it "version"), your VCS shows you exactly how it differed from the
previous one.

Version control is independent of the kind of project / technology / framework you're working
with:

● It works just as well for an HTML website as it does for a design project or an iPhone app
It lets you work with any tool you like;
● it doesn't care what kind of text editor, graphics program, file manager or other tool you
use Also, don't confuse a VCS with a backup or a deployment system.

You don't have to change or replace any other part of your tool chain when you start using
version control. A version control system records the changes you make to your project's files.
This is what version control is about. It's really as simple as it sounds.
Why Use a Version Control System?

Collaboration

Storing Versions (Properly)

Restoring Previous Versions

Understanding What Happened

Backup
KEYWORDS
GIT WORKFLOW
How to install Git ?
Installation of Git on Linux Ubuntu OS

● You can check your current version of Git by running the command in a
terminal.

git --version

● Using package manager to install or upgrade Git.

sudo apt-get install git

● You can confirm that you have installed Git correctly by running the
following command

git --version
● After installing Git make sure your username and email address are set
correctly.

git config --list

● If your name and email are not listed in the output, use the following
commands to set them manually.

git config --global user.name "VEERESH H R"

git config --global user.email "veeresh.hr@c2info.com"


Installation of Git on Windows and
Mac
● To install Git-bash on Windows OS :

https://www.youtube.com/watch?v=t7pasiwt-Yw

Git Bash is an application for Microsoft Windows environments which provides an


emulation layer for a Git command line experience.

● To install Git on Mac OS :

https://www.youtube.com/watch?v=LK0vMt_lEbQ

https://www.atlassian.com/git/tutorials/install-git
Basic Commands
pwd : command prints the absolute path to current working directory.

cd : changes directory.

cd .. : to go back to previous directory.

cd ~ : to return back to users home.

ls : lists directory contents.

ls -a : lists directory contents with hidden folders.

date : shows the date and time.

mkdir : to create a folder.


touch today.txt :to create new file of any format

nano today.txt : to edit the file

rm test.txt : removes files

rmdir test : removes directories

cp today.txt /f/git-project : to copy files and directories to the locations

mv today.txt /f/git-project/new-location : to move files and directories to the locations


Git Commands
git init : Create an empty Git repository or reinitialize an existing one

git status : Show the working tree status

git add file.txt : Add file contents to the staging index

git add . : Adds everything from working index to staging index.

git reset HEAD new.txt : unstages from staging index to working index.

git checkout --new.txt : to remove all the changes of the file until last commit.

git commit -m "My first commit" : Record changes to the repository


Rules that everyone should follow while
using git

1 Always commit your code at the end of day.

2 Always pull code first and the push the code to


repo.
git clone https://github.com/git/git.git : to get a copy of an existing git repository or
project.

git pull origin master : The "push" command is used to publish new local commits on a
remote server.

git push origin master : To get the code from the remote server.

git log : Inspecting the Commit History

git show shaId : Shows the difference between latest commit and prior to latest one.

git diff HEAD : shows the difference between working index and latest commit.

git diff : shows the difference between working index and staging index.
git diff --staged : shows the difference between staging index and latest commit.

git diff shaId1 shaId2 : shows the difference between two commits.

git diff head head^ : Difference between HEAD and HEAD-1 commit.
Conflict Resolution
LEARNING GIT
● Git website: https://git-scm.com/
● Git tutorial : https://www.git-tower.com/learn/git/ebook/en/command-line/introduction
● Udemy free course on Git :
https://www.udemy.com/course/git-and-github-crash-course-creating-a-repository-from-scratch/
● Udemy Git: Become an Expert : https://www.udemy.com/course/git-expert-4-hours/
● Free online book: https://git-scm.com/book/en/v2
● Reference page for Git: https://services.github.com/index.html
● Git tutorial: http://schacon.github.com/git/gittutorial.html
● Git for Computer Scientists: https://eagain.net/articles/git-for-computer-scientists/
Thank you for your
valuable time.

VEERESH H R

Вам также может понравиться