Slide 1

Slide 1 text

Introduction to VCS

Slide 2

Slide 2 text

@AlexeyBuzdin Developer / Trainer at

Slide 3

Slide 3 text

How to work in a team?

Slide 4

Slide 4 text

Solutions? • FTP server • Dropbox • USB drive

Slide 5

Slide 5 text

What do we need? • “Checkout-Change-Commit” approach • Disable concurrent changes • Changes history

Slide 6

Slide 6 text

Version Control System • Tool for managing a *collection of files and its content. • *Collection is called a Repository

Slide 7

Slide 7 text

When to VCS? • Almost every time you write code! • Great even for a single file

Slide 8

Slide 8 text

Dvcs vs Cvcs master repo all repo are equal

Slide 9

Slide 9 text

Dvcs vs Cvcs master repo all repo are equal

Slide 10

Slide 10 text

Popularity in OS Eclipse Community Survey

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Merge Conflicts

Slide 13

Slide 13 text

Git Essentials

Slide 14

Slide 14 text

Git is a DVCS • Everything is done locally (check in / commit / branch / merge) • Collaboration via repository sync • Peer to Peer approach (all repo are equal) • Stores history locally (Distributed Version Control System)

Slide 15

Slide 15 text

Pros and Cons • Fast revision checkout • Offline usage • Local commits • Full control over VCS • Binary snapshot history • Repos can be heavy on first checkout due to local history • Hard to master

Slide 16

Slide 16 text

Install Git • http://git-scm.com/ • http://www.sourcetreeapp.com/ Git itself: GUI app:

Slide 17

Slide 17 text

Configure Git Credentials: • git config —global user.name alexey.buzdin • git config —global user.email [email protected] ~/.gitconfig - global REPO/.git/config - local

Slide 18

Slide 18 text

[merge] tool = p4merge keepBackup = false [mergetool "p4merge"] cmd = p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED" keepTemporaries = false trustExitCode = false keepBackup = false prompt = false [difftool] external = p4diff [push] default = current [credential] helper = osxkeychain [branch] autosetuprebase = always [user] name = alexey.buzdin email = [email protected] [mergetool] keepBackup = false prompt = false [alias] st = status [core] autocrlf = input excludesfile = /Users/alexeybuzdin/.gitignore_global [difftool "sourcetree"] cmd = opendiff \"$LOCAL\" \"$REMOTE\" path = [mergetool "sourcetree"] cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merg \"$MERGED\" trustExitCode = true vim ~/.gitconfig

Slide 19

Slide 19 text

.gitignore # NuGet dependencies packages/ # Android module specifics **/Resource.designer.cs # Shared files **/bin/ **/obj/ *_ReSharper.*/ # Misc files *.user *.suo *.userprefs *.DS_Store *.swp # Migration .svn

Slide 20

Slide 20 text

New Git Project • mkdir git-introduction; cd git-introduction • git init • git remote add origin https://github.com/LArchaon/learning-git-repo.git • git fetch • git checkout master

Slide 21

Slide 21 text

New Git Project • mkdir git-introduction; cd git-introduction • git init • git remote add origin https://github.com/LArchaon/learning-git-repo.git • git fetch • git checkout master or • git clone https://github.com/LArchaon/learning-git-repo.git

Slide 22

Slide 22 text

Git help • git help • git --help

Slide 23

Slide 23 text

Git lifecycle

Slide 24

Slide 24 text

Example • echo "Hello World" > a.txt • git status • git add a.txt • git status • git commit -m ”Initial commit” • git status • ???

Slide 25

Slide 25 text

Git lifecycle git add <filename> git add <filename> git commit git rm —cached <filename>

Slide 26

Slide 26 text

Commit

Slide 27

Slide 27 text

Branching

Slide 28

Slide 28 text

Branching @

Slide 29

Slide 29 text

Navigation • git checkout 98ca9 • git checkout master • git checkout v1.0 • git checkout @ or git checkout HEAD

Slide 30

Slide 30 text

Branching • git branch newBranch • git checkout newBranch or • git checkout -b newBranch

Slide 31

Slide 31 text

Branching

Slide 32

Slide 32 text

Branching

Slide 33

Slide 33 text

Branching

Slide 34

Slide 34 text

Merge

Slide 35

Slide 35 text

Merge • git checkout master • git merge iss53 • enter commit message “C5”

Slide 36

Slide 36 text

Merge

Slide 37

Slide 37 text

Merging Pros • Simple to use and understand. • Maintains the original context of the source branch. • The commits on the source branch remain separate from other branch commits. This separation can be useful in the case of feature branches, where you might want to take a feature and merge it into another branch later. • Existing commits on the source branch are unchanged and remain valid; it doesn’t matter if they’ve been shared with others.

Slide 38

Slide 38 text

Merging Cons • If the need to merge arises simply because multiple people are working on the same branch in parallel, the merges don’t serve any useful historic purpose and create clutter.

Slide 39

Slide 39 text

Rebase

Slide 40

Slide 40 text

if Merge done

Slide 41

Slide 41 text

if Rebase done • git checkout experiment • git rebase master

Slide 42

Slide 42 text

then • git checkout master • git merge experiment

Slide 43

Slide 43 text

Rebase Pros • Simplifies your history. • Is the most intuitive and clutter-free way to combine commits from multiple developers in a shared branch

Slide 44

Slide 44 text

Rebase Cons • Slightly more complex, especially under conflict conditions. Each commit is rebased in order, and a conflict will interrupt the process of rebasing multiple commits. With a conflict, you have to resolve the conflict in order to continue the rebase. • Rewriting of history has ramifications if you’ve previously pushed those commits elsewhere.

Slide 45

Slide 45 text

Lets get hardcore! • git rebase --onto master server client

Slide 46

Slide 46 text

more!!! “Check out the client branch, figure out the patches from the common ancestor of the client and server branches, and then replay them onto master.”

Slide 47

Slide 47 text

then • git checkout master • git merge client

Slide 48

Slide 48 text

morrreee…. • git rebase master server

Slide 49

Slide 49 text

Success! • git checkout master • git merge server • git branch -d client • git branch -d server

Slide 50

Slide 50 text

You feeling?

Slide 51

Slide 51 text

• …. • git commit -m ”My commit” • git pull • git push

Slide 52

Slide 52 text

Git pull • git pull = git fetch + git merge /branch

Slide 53

Slide 53 text

Merge bubble • git pull = git fetch + git merge /branch

Slide 54

Slide 54 text

• …. • git commit -m ”My commit” • git stash • git pull --rebase • git push • git stash apply

Slide 55

Slide 55 text

Clean and pretty

Slide 56

Slide 56 text

• git pull —rebase • git push

Slide 57

Slide 57 text

• git pull —rebase int-mng master • git push int-mng master

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

http://git-scm.com/book/

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

Countries Chapters Events 106 601 3222

Slide 65

Slide 65 text

gdgriga.lv

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

https://developers.google.com/groups/ Find us at

Slide 68

Slide 68 text

May 28 - 29, 2015 https://events.google.com/io2015/

Slide 69

Slide 69 text

May 28 - 29, 2015 https://www.youtube.com/watch?v=ksvdvCDO7pA

Slide 70

Slide 70 text

Q&A Thank You!