4. What is GIT?
● GIT is a distributed revision controlled
source code management system (DVCS)
● GIT were created, designed and developed
by Linus Torvalds (the creator of Linux) for
Linux kernel development
(See Linus Torvalds in YouTube)
● Official GIT site: http://git-scm.com
6. Why use GIT?There are many other SCM/SVCS systems out there...
● GIT is fast
● GIT has no need for network connection -
for most operations
● GIT is a great merge and branching tool
● GIT is a modern tool
● GIT have a very large install-base
● GIT encourage developers to commit, which
results with less data lose
7. GIT is distributed
● There is no single server – each endpoint
contains all the information.
● Usually there is one endpoint that is considered as
the central one but this is not a must.
● The common flow:
o You clone the central repository and/or sync
with its content
o You work offline on your private repository
o You push your local changes into the central
repository
9. GIT is fast
● For most operations you need no network
connection
● Network operations are done very fast using
modern and validated transfer actions
● GIT uses snapshots of the whole repository
instead of the files-and-delta technology
● GIT uses pointers
● GIT is optimized for merge...
10. GIT is optimized for merge
● GIT is designed for fast and efficient merge
● GIT supports:
o Local merge
o 2 repositories/endpoints merge
o Simultaneously work on the same resource
o Merge is usually done locally before
pushing it to the remote repository so it is
very easy to abort it or revert to the previous
status
12. Things you must consider
about GIT
● GIT is not CVS or SVN or any of
those tools
● GIT requires much to learn about it
● GIT command line interface (CLI) is
the most recommended client for it
16. GIT repositoryThe multiple commit concept
● Each commit store a pointer to the former
(checksum) commit
● The first commit has a null pointer
17. GIT branchesBasic terms
● branch – a pointer to some commit
● master – the “default” branch
● HEAD – the current branch of the local/remote repository
● origin – the remote repository (usually – the one you have
cloned from)
● origin/master – the master branch (pointer) of the origin
repository
18. GIT local work
GIT directory
...is where Git stores the metadata and object database for your project
Working directory
...is a single checkout of one version of the project on your disk.
Staging area (Index)
...is a simple snapshot file in your Git directory, that stores information about what will go
into your next commit.
Why staging?
● Gives you the ability to control the content of your next commit
● You can reset changes
● You can 'stash' all changes and work on a new task in the same location
● Once you’re done with your code – for committing - you can:
o Review the differences between working directory and staging
o Review the differences between staging and HEAD
21. GIT basic flow
The common flow
● You clone the central repository and sync with its content:
o git clone <remote repository URL> - cloning the
repository
o git pull origin master - sync with remote repository
● You work offline on your private repository
o git add --all - staging all new and/or removed files
o git commit -m “<comment>” - commit changes
● You push your local changes into the central repository
o git push origin master
23. Other GIT common commands
● git clone – clone a repository into a new copy
● git status – show the status of your local repository
● git log – show commit logs
● git diff - show the differences between anything: states, branches
and more
● git branch – perform branch-related actions such as create
branch, list branches and more
● git checkout – switch to work on a certain snapshot (branch, hash,
tag)
● git merge – merge into current working snapshot
● git cherrypick – merge picked commits from branch to branch
24. Let’s GIT started
● Install GIT (usually from http://git-scm.com)
● Initial GIT global settings
● git config --global user.name “Bill Gates”
● git config --global user.email bill.gates@microsoft.com
● GIT repository initiate:
● mkdir microsoft
● cd microsoft
● git init
or
● GIT clone:
● git clone git@microsoft:acquired-companies/someTool.git
33. Centralized Workflow
If your developers are already
comfortable with Subversion, the
Centralized Workflow lets you
experience the benefits of Git
without having to adapt to an
entirely new process. It also
serves as a friendly transition
into more Git-oriented
workflows.
See more...
34. Feature Branch Workflow
The Feature Branch Workflow
builds on the Centralized
Workflow by encapsulating new
features into dedicated
branches. This enables the use
of pull requests as a means to
discuss changes before they’re
integrated into the official
project.
See more...
35. Gitflow Workflow
The Gitflow Workflow
streamlines the release cycle
by using isolated branches
for feature development,
release preparation, and
maintenance. Its strict
branching model also lends
some much needed structure
to larger projects.
See more...
36. GitHub Flow
what is GitHub Flow?
● Anything in the master branch is deployable
● To work on something new, create a descriptively named
branch off of master (ie:new-oauth2-scopes)
● Commit to that branch locally and regularly push your
work to the same named branch on the server
● When you need feedback or help, or you think the branch
is ready for merging, open a pull request
● After someone else has reviewed and signed off on the
feature, you can merge it into master
● Once it is merged and pushed to ‘master’, you can and
should deploy immediately
See more...
37. Forking Workflow
The Forking Workflow is a
distributed workflow that takes
full advantage of Git’s branching
and cloning capabilities. It
provides a safe, reliable way to
manage large teams of
developers and to accept
commits from untrusted
contributors.
See more...
38. Pull requests
Pull request (sometimes called
merge request) is a feature that
makes it easier for developers to
collaborate using the hosting
service. It provides a user-
friendly web interface for
discussing proposed changes
before integrating them into the
official project.
See more...