SVN | Mercurial (hg) | git | |
---|---|---|---|
Type | CVCS | DVCS | DVCS |
Storage method | Changeset/Snapshot | Changeset | Snapshot |
Learning Curve | Easy | Moderate | Steep |
Developed in | C | Python | C/perl/shell scripts |
Speed | Slow | Fast | Very Fast |
Branching | Easy | Free | Free |
Merging | Difficult | Pretty easy> | Piece of cake |
Data Integrity | Primitive | SHA-1 | SHA-1 |
Space Requirements | Big | Small (efficient for small projects) | Small (efficient for big projects) |
History rewriting | No | Yes | Yes |
VCS Collaboration | No | Yes | Yes |
Integration with IDEs | Yes | Yes | Yes |
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --list
user.name=John Doe
user.email=johndoe@example.com
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
...
git init
$ git init tutorial
tutorial
is createdtutorial
, .git
directory holds all repository informationgit status
$ git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
working directory
→ sandbox, holds the filesindex
→ snapshot of changes proposed for next revisionHEAD
→ pointer to last snapshot init
also creates master
default & active branch
HEAD
(usually) points where the branch points$ touch first
working directory
$ git add first
index
HEAD
and master
point to new commit$ git commit first
$ git commit -a first
$ git log --decorate --graph
* commit 8484f4fccb80e625b7c05cdc214014a32d176777 (HEAD)
| Author: Panagiotis Papadakos <papadako@gmail.com>
| Date: Tue Oct 20 01:15:40 2015 +0300
| Add some content
HEAD
points$ git branch featureX && git branch bugY
master
is the default branch (commit
still updates the master
pointer)<name>
a branch name or commit object (if not given, HEAD
) git
won't switch to another branch (use git commit
/git stash
)$ git checkout featureX
featureX
master
by:git checkout master
git merge featureX
featureX
master
master
with featureX
git
has no problem!git merge -no-ff
will create a new commitgit
tries hard and is smart enough in avoiding themgit add
resolved files and then commit
<<<<<<< HEAD
I am the bug!
=======
No, I am the bug!
>>>>>>> master
Resolve bug
git
does not have a central repository like SVN
branch
, pointing to other repo's commit objectsgit remote
- Create connections & give nick names to online repos$ git remote add forU https://github.com/papadako/git-a-little-tale.git
origin
(like master
for init
)$ git clone https://github.com/papadako/git-a-little-tale.git
$git fetch origin
(fetches all online branches of remote origin
)$git fetch origin bname
(fetches only origin/bname
)pull
makes this two step process in a single step$ git pull
is the same as:$ git fetch <remote>
$ git merge origin/<current-branch>
merge
--all
or --tags
flags)--force
if you really need this CAUTIONbranch
, HEAD
to specific commitindex
and working directory
do not changeindex
or from index
and working directory
branch
, HEAD
, index
and working directory
to specific commitgit tag -a v4.4.4 -m 'my lucky version'
git stash
adds the modified files and staged changes in a stackgit stash pop
re-inserts the files to the current branchgit mv
(commit both the old and new file)clone
)git push origin master
git pull
github | Bitbucket | gitlab | |
---|---|---|---|
DVCS | git & hg | hg & git | git |
Free public repos | Yes (unlimited members) |
Yes (team < 6) |
Yes |
Free private repos | No | Yes (team < 6 - unlimited for academy) |
Yes |
Size of repos | Unlimited | 2Gb | 10Gb |
Deployed | Cloud | Cloud | Cloud or own server (paid) |
Issues | Yes | Yes | Yes |
Social Aspect | Strong (OS) | Not strong | New kid on the block |
Pull requests | Yes | Yes | Yes |
Wikis | Yes | Yes | Yes |
Project Deployment | No | No | Yes |
Code Statistics | Best | Moderate | ? |
Γεγόναμεν ἅπαξ, δὶς δὲ οὐκ ἔστι γενέσθαι
δεῖ δὲ τὸν αἰῶνα μηκέτι εἶναι
σὺ δὲ οὐκ ὢν τῆς αὔριον κύριος ἀναβάλλῃ τὸ χαῖρο
ὁ δὲ βίος μελλησμῷ παραπόλλυται καὶ εἷς ἕκαστος ἡμῶν ἀσχολούμενος ἀποθνῄσκει.
We have been born once and cannot be born a second time; for all eternity we shall no longer exist. But you, although you are not in control of tomorrow, are postponing your happiness. Life is wasted by delaying, and each one of us dies without enjoying leisure.