Introduction to Git source control, i will start a simple series as quick start to you for Git, this is only part 1, after finish it you will get the concept behind Git with simple example
1. Git
Part 1
BY MOHAMED ABDEEN
SOFTWARE / SHAREPOINT CONSULTANT
WWW.MOHAMEDABDEEN.COM
2015
2. About Mohamed Abdeen
Is Software / SharePoint Consultant
6+ years of software & IT industry , Microsoft SharePoint experience,
Microsoft Certified Trainer
4. 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
5. Objective
• Know new Source control called Git.
• Know git source control concept
• Know more about the git tools
• Be familiar with git basics
6. Source Control types
Local Version Control Systems Centralized Version Control Systems Distributed Version Control Systems
7. 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.
8. Git is Snapshot not differences
Most other systems store information as a list
of file-based changes. These systems (CVS,
Subversion, Perforce, Bazaar, and so on) think
of the information they keep as a set of files
and the changes made to each file over time
Every time you commit, or save the state of your
project in Git, it basically takes a picture of what all
your files look like at that moment and stores a
reference to that snapshot. To be efficient, if files
have not changed, Git doesn’t store the file again—
just a link to the previous identical file it has already
stored.
10. 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
11. Before we start … Download it
Download
The download includes the following:
• Git engine
• Git command line tool
12. For GUI fans
There are many tools for GUI tools
You can check more Git GUI
tools on the following link …
Click Here
14. 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
15. 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
16. 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.
17. 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
18. 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
19. 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.
20. 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.
21. 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.
22. See you in the next part
Git and Remote servers
like TFS, GitHub, Bitbuck
Git Series
By Mohamed Abdeen