Escolar Documentos
Profissional Documentos
Cultura Documentos
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Motivation
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Motivation
Decentralized
Faster, really. Complete repository clone. Developers can work offline, committing all their work locally and pushing to a primary repository later. Redundant and enterprise-ready, if required.
Lightweight Branches
Cheap and quick Used often, and merged often.
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Motivation
Drives for better development methodology
Gitflow A successful git branching model Code reviews
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Roadmap
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Roadmap
Plans for implementing Git in HP Live Network.
Git kick-off
Motivation for Git Roadmap
Using Git
Preliminary evaluation of Git Understanding Git knowledge gap Migrating backend SVN repository to Git Using Git in a single team (3 developers) as case study
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Overview
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Overview
CVCS
SVN operations mostly need to consult a remote server repository
DVCS
Git operations mostly run on the local repository (and later pushed to a remote server)
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Overview
Changes
SVN-like data model
Gnapshots
Git maintains a snapshot of the data
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Overview
The Three States
Modified Staged (the staging area is also known as the index) Committed
10
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Overview
Git For Work
IntelliJ In our experience Eclipse with EGIT support is awful PHPStorm bundled with Git integration Command line Git, my preferred option
11
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Initializing a git repository Starting fresh
git init
13
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Adding work Commiting your work
git add <file> git add -p <file> git add -I <file> git status git commit [file] -m <commit-message>
14
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Common commands Commiting your work
git status git branch git diff --staged see changes between staged to last commit git rm git mv .gitignore git log -p view diff --stat view a summary of commit file stats --pretty=oneline --pretty=full or --pretty=format:%h - %an, %ar : %s --graph --since=2.weeks Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 15
Git Basics
Undoing Undoing changes
git commit amend Commits the staging area again instead of the previous commit
git reset HEAD <file> Unstage a previously staged file git checkout -- <file> Revert local changes to that file
16
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Remotes Working with Remotes
git remote -v Lists remotes configured for this repository
git remote add <shortname> <url> Adding a remote git fetch <remote> <branch> Fetch the changes from the remote repository (not yet merging them) git pull <remote> <branch> Fetch and merge changes from the remote repository to the local branch
17
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Remotes Working with Remotes
git push <remote> <branch> Push your changes to the remote repository Pushing is only successful if your local copy is up to date with the remote git remote show <remote> Inspecting the remote for information
git remote rename <remote> <new-remote> Renaming a remote git remote rm <remote> Removing a remote
18 Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Basics
Tagging Lightweight and Annotated Tags
git tag -a v2.0 -m portal release 2.0 [hash] Annotated tags (notice the -a flag) are saved as full Git objects meaning they contain author information, email, checksum, etc.
git tag v2.0 Lightweight tags are just pointers to a commit (dont provide -a, -m or -s) git push <remote> --tags Pushing our tags to the remote repository as they dont get pushed with a plain git push
19
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Overview
Diverge from the main line of development and continue to do work without messing with that main line Expensive process, often requiring you to create a new copy of your source code directory
21
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Overview
Stream-line a development methodology
22
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Starting off
Starting on a fresh master branch with 3 files: README License test.rb After performing git add && git commit, an example visual representation is as such:
23
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Starting off
With each commit in time a new commit object is created and objects are pointing to parents (zero or more)
24
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Starting off
The master branch is simply a pointer that moves forward with each commit you make
25
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Branching off
Creating new branches means creating new pointers to a certain commit git branch testing
26
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Branching off
HEAD pointer is used to point to the local branch youre working on now Were still on master cause we only created a new branch (testing) but didnt yet switch to it
27
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Branching off
HEAD pointer is used to point to the local branch youre working on now Were still on master cause we only created a new branch (testing) but didnt yet switch to it git checkout testing
28
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Branching off
HEAD and testing branch pointers are both updated with each new commit git commit -a -m new file
29
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Branching off
Going back to our original master branch: Updated the HEAD pointer Working directory looks different now, representing the state of the master branch git checkout master
30
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Diverged road
Commiting work on the master branch again will diverge and enable us to work on 2 paths git commit -a -m another commit
31
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Git Branches
Re-cap
Branches are simply pointers Due to commits data structure it is easy enough to find proper merge base and that process is mostly done automatic for us
32
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Gitblit
Gitblit
Open source Java project for hosting Git repositories Includes a web interface for managing and interacting with repositories (attempts to live up to the Github promise)
34
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Gitblit
Gitblit
Open source Java project for hosting Git repositories Includes a web interface for managing and interacting with repositories (attempts to live up to the Github promise) Includes a Java UI to manage users and their certificates Feature-full, including repository federation and other cool stuff
35
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Gitblit
User Setup
Configure your git: git config --global http.sslverify false git config --global http.sslkey /pathto/lirantal.key git config --global http.sslcert /pathto/lirantal.pem git config --global http.proxy "" git config --global user.name "Liran Tal" git config --global user.email "liran.tal@hp.com" Youre ready to clone: git clone https://gitserver:8443/git/hpln.git
36
Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.