22
Git Part 1 BY MOHAMED ABDEEN SOFTWARE / SHAREPOINT CONSULTANT WWW.MOHAMEDABDEEN.COM 2015

Git Series - Part 1

Embed Size (px)

Citation preview

Page 1: Git Series - Part 1

Git

Part 1BY MOHAMED ABDEEN

SOFTWARE / SHAREPOINT CONSULTANT

WWW.MOHAMEDABDEEN.COM

2015

Page 2: Git Series - Part 1

About Mohamed Abdeen

Is Software / SharePoint Consultant

6+ years of software & IT industry , Microsoft SharePoint experience,

Microsoft Certified Trainer

Page 4: Git Series - Part 1

Agenda Objective of the session

Source control types

What is the git ?

Git is Snapshot not differences

Who Use Git ?

Git vs. other source control

Git & Three States

Before we start … Download it

Git Repository Directory

File Status Life Cycle

Working with Remote Server

Git vs. other source control

Page 5: Git Series - Part 1

Objective

• Know new Source control called Git.• Know git source control concept• Know more about the git tools • Be familiar with git basics

Page 7: Git Series - Part 1

What is Git ?

Git is a free and open source distributed version control system designed to handle

everything from small to very large projects with speed and efficiency.

Every Git working directory is a full-fledged repository with complete history and full

version tracking capabilities, not dependent on network access or a central server.

Page 8: Git Series - Part 1

Git is Snapshot not differences

Most other systems store information as a listof file-based changes. These systems (CVS,Subversion, Perforce, Bazaar, and so on) thinkof the information they keep as a set of filesand the changes made to each file over time

Every time you commit, or save the state of yourproject in Git, it basically takes a picture of what allyour files look like at that moment and stores areference to that snapshot. To be efficient, if fileshave not changed, Git doesn’t store the file again—just a link to the previous identical file it has alreadystored.

Page 9: Git Series - Part 1

Who Use Git ?

Page 10: Git Series - Part 1

Git & Three States

Git has three main states that your files can reside in: committed, modified, and staged.

Committed means that the data is safely stored in your local database.

Modified means that you have changed the file but have not committed it to your database yet.

Staged means that you have marked a modified file in its current version to go into your next commit snapshot.

Modify files in your working directory

stage the files, adding snapshots of them to your

staging area

do a commit, which takes the files as they are in the staging area and stores that snapshot

permanently to your Git directory

Page 11: Git Series - Part 1

Before we start … Download it

Download

The download includes the following:

• Git engine

• Git command line tool

Page 12: Git Series - Part 1

For GUI fans

There are many tools for GUI tools

You can check more Git GUI

tools on the following link …

Click Here

Page 13: Git Series - Part 1

Git Basics

Working Directory Local Repository Remote Repository

Page 14: Git Series - Part 1

Git Basics … Files Status

Files has to be:1. Tracked files that were in the last snapshot [unmodified – modified – staged ]

2. Un Tracked any files in your working directory that were not in your last

snapshot and are not in your staging area

Get the status of files in working directory

Page 15: Git Series - Part 1

Start with Git

1. Takes an existing project or directory and imports it into Git.

2. Clones an existing Git repository from another server.

Initializing a Repository in an Existing

Directory

$ git init

Create new sub directory named .git that

contains all of your necessary files, at this

point, nothing in your project is tracked

yet

$ git add *.c

$ git add README

Track the file and added to the local rep

$ git commit -m 'initial project version'

Commit the files to local repository

Initializing a Repository in an Existing Directory

get a copy of an existing Git repository

$ git clone git://github.com/abdeen/grit.git

$ git clone git://github.com/abdeen/grit.git mygrit

That creates a directory named grit directory inside

it, pull down all the data for the repository and

checks out a working copy of the least version

Page 16: Git Series - Part 1

Git Repository Directory The Git directory is where Git stores the

metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.

The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.

The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area.

Page 17: Git Series - Part 1

Working with Remote Server

Remote repositories are versions of your project that are hosted on

the Internet or network somewhere. You can have several of them,

each of which generally is either read-only or read/write for you.

Collaborating with others involves managing these remote

repositories and pushing and pulling data to and from them when you need to share work.

Git remote && git remote -v

Page 18: Git Series - Part 1

Git vs. other source control

1. Branching & Merging

Git allows and encourages you to have multiple local branches

that can be entirely independent of each other. The creation,

merging, and deletion of those lines of development takes

seconds.

Create a branch to try out an idea, commit a few times, switch

back to where you branched from, apply a patch, switch back

to where you are experimenting, and merge it in.

Create new branches for each new feature you're working on so

you can seamlessly switch back and forth between them, then

delete each branch when that feature gets merged into your

main line.

Notably, when you push to a remote repository, you do not have

to push all of your branches. You can choose to share just one of

your branches, a few of them, or all of them

Page 19: Git Series - Part 1

Git vs. other source control

2. Small and Fast

Git is fast. With Git, nearly all operations are

performed locally, giving it a huge speed

advantage on centralized systems that

constantly have to communicate with a server

somewhere.

Git is one or two orders of magnitude faster

than SVN, even under ideal conditions for SVN.

One place where Git is slower is in the initial

clone operation. Here, Git is downloading the

entire history rather than only the latest

version.

3. Distributed

This means that instead of doing a

"checkout" of the current tip of the source

code, you do a "clone" of the entire repository.

This means that even if you're using a

centralized workflow, every user

essentially has a full backup of the main

server.

Page 20: Git Series - Part 1

Git vs. other source control

4. Data Assurance

Every file and commit is check summed and retrieved by its checksum when checked

back out. It's impossible to get anything out of Git other than the exact bits you put in.

It is also impossible to change any file, date, commit message, or any other data in a

Git repository without changing the IDs of everything after it. This means that if you have

a commit ID, you can be assured not only that your project is exactly the same as when it was committed, but that nothing in its history was changed.

Page 21: Git Series - Part 1

Git vs. other source control

5. Staging Area

This is an intermediate area where commits can be formatted and reviewed before

completing the commit.

it's possible to quickly stage some of your files and commit them without committing

all of the other modified files in your working directory or having to list them on the

command line during the commit.

Page 22: Git Series - Part 1

See you in the next part

Git and Remote servers

like TFS, GitHub, Bitbuck

Git Series

By Mohamed Abdeen