Date post: | 22-Jan-2018 |
Category: |
Technology |
Upload: | yoram-michaeli |
View: | 4,276 times |
Download: | 0 times |
Before you GIT it...
What is GIT?
What is GIT?
● GIT is a distributed revision controland 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
Why use GIT?
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 loose
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:● You clone the central repository and sync with its
content● You work offline on your private repository● You push your local changes into the central
repository
GIT is distributed
GIT is fast
● For most operation you don't need 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...
GIT is optimized for merge
● GIT is designed for fast and efficient merge● GIT supports:
● Local merge● 2 repositories/endpoints merge● Simultaneously work on the same resource
● 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
Things you must consider about GIT
Things you must consider about GIT
● GIT requires you to understand it for using it● 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
GIT concepts overview
SVN/CVS vs. GIT
GIT commit representation
GIT repository – the multiple commit concept
Each commit store a pointer to the former (checksum) commit The first commit has a null pointer
GIT branches – basic terms
branch – a pointer to some commitmaster – the “default” branchHEAD – the current branch of the local/remote repositoryorigin – the remote repository (usually – the one you have cloned from)origin/master – the master branch (pointer) of the origin repository
GIT local workGIT directoryis where Git stores the metadata and object database for your project
Working directoryis 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 commitYou can reset changesYou can 'stash' all changes and work on a new task in the same locationOnce your done with your code – for committing - you can:
Review the differences between working directory and stagingReview the differences between staging and HEAD
A GIT file life-cycle
GIT basic flow and operations
The common flow:● You clone the central repository and sync with its content:
– Method 1:
> git pull
– Method 2:
> git fetch > git rebase
● You work offline on your private repository
> git add --all > git commit -m “<comment>”
● You push your local changes into the central repository
> git push origin master
GIT basic flow
GIT common actions & flow
● 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
Other GIT common commands
Let's GIT startedInstall GIT (usually from http://git-scm.com/)Initial global settings
> git config --global user.name “Bill Gates”
> git config --global user.email “[email protected]”
> git config --global color.ui true
git init > mkdir microsoft
> cd microsoft
> git init
or git clone > cd Microsoft
> git clone git@microsoft:acquired-companies/someTool.git
GIT tools
GIT hosting tools and services
GIT cloud-based hosting services
https://git.wiki.kernel.org/index.php/GitHosting
GIT on-premise hosting tools
http://en.wikipedia.org/wiki/Comparison_of_free_software_hosting_facilities
Detailed guideline for choosing GIT host service
http://www.slideshare.net/YoramMichaeli/git-hostingservice
GIT client tools
GIT GUI client tools
https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools
SourceTree
GitHub
GitX
Gitg
SmartGit
GIT branching model
GIT branching modelbased on http://nvie.com/posts/a-successful-git-branching-model
GIT more
Other GIT great starting points
Pro GitGIT REAL