Git presentation, Viktor Pyskunov

Post on 03-Sep-2014

671 views 0 download

Tags:

description

Introducing Git Principles and How-To Use

Transcript of Git presentation, Viktor Pyskunov

Git

Distributed Version Control System

by Viktor Pyskunov

About

• Created by Linus Torvalds, author of Linux• Very fast• Used in Linux kernel development• Makes working with branches really fun• Better conflict resolution• Working offline• There are no hundreds of .svn directories all over the

code, instead only one .git directory in the root of project• Comfortable to work with commits

Git design objectives

• Distributed• No central repo• Everyone is on her own island

• Performance• Branching and merge is cheap• Diff the whole kernel tree in less than 1 second• Store the KDE tree in less than 2GB while SVN takes

8GB

SVN Way

• Commit concurrency• Slow history• Unstaged changes that may be lost due to conflicts

Git Way

• Every developer has their own repo• Fast history as well as commits• A lot of local commits before pushing• Code staging decreases possibility of data loss

Git Entities

• Working directory• Index, or staging• Local repository• Remote repository

Git Commands Dealing with Entities

Generate ssh Key

Click on Start->Programs->TortoiseGit->PuttyGenGenerateSave private key

Console:ssh-keygen

Generate ssh Key

Don’t close the windowSave this key somewhereStart->Programs->TortoiseGit->Pageant

Typical Git Workflow

• Pull from remote repository• Edit files• Add• Commit• Edit files again together with new ones• Add• Commit• Push to remote repository

Typical Git Workflow Visualized

Extended Git Workflow

• Pull from remote repository• Create new branch from common branch• Edit files• Add• Commit• Edit files again together with new ones• Add• Commit• Merge your working branch to common branch• Resolve conflicts• Delete working branch• Push to remote repository

Tortoise Git

Cloning Repository

Console:git clone <path_to_repository>

Initial Repository

History

Console:git log

Adding new file

Console:git add <file1> <file2> …

Committing Changes

Console:git commit <file1> <file2> …

History with New Commit

New Branch with the Third File

Console:git branch <name_of_branch>

Adding File

Committing File in Branch

Switching to Master

Console:git checkout <name_of_branch>

Merge from Branch to Master

Console:git merge <name_of_branch>

Master After Merge

Branches After Merge

Push Your Modifications

Checkbox will push all your branchesIf unchecked, only selected branches will be pushed

Console:git push <repository> <branch>

Fetch with rebase

Using fetch with rebase instead of pull will flatten history of commits to make it sequential

Console:git pull --rebase

Reverting Commit

Console:git revert <hash_of_commit>

References

• Book http://progit.org/book/• Tools

http://guides.beanstalkapp.com/version-control/clients.html