Introduction to git administration

32
Introduction to Git Administration For New Administrators Shawn Doyle ReleaseTEAM Inc [email protected] www.linkedin.com/in/releasete am / http://twitter.com/ReleaseTEA

description

Short set of slides, brief intro to Git then shared experiences migrating from other SCM tools to Git.

Transcript of Introduction to git administration

Page 1: Introduction to git administration

Introduction to Git Administration

For New Administrators

Shawn DoyleReleaseTEAM [email protected]/in/releaseteam/http://twitter.com/ReleaseTEAMInc

Page 2: Introduction to git administration

Premium SCM Consulting firm since 1999Focus on Software Configuration Management

On site and remote consulting services– Build Automation– CM tool administration, customization, upgrades,

migrations

Classroom training / hands-on mentoring

ReleaseTEAM, Inc.

ClearCase ClearQuest Jenkins

Git RTC Build Forge

SVN Jira Electric Commander

Shawn Doyle - ReleaseTEAM

Page 3: Introduction to git administration
Page 4: Introduction to git administration

Subversion & Git Presentation

For the administrator new to Git An overview of Git Workflows  Common admin tasks

Access control Triggers

Stories from the trenches

Agenda

Slide 4

Page 5: Introduction to git administration

So you now are a Git Admin

Page 6: Introduction to git administration

Subversion & Git Presentation

Git has sprung up in many organizations. Spreading like a wild fire from the development groups.– Developers want less restrictions to their productivity– SCM is always seen as a restriction and rarely a

necessary one

SCM admins are finding they need to support Git regardless of existing corporate standards.SCM admins need to find a way to control the chaos.Most commercial SCM tools now support Git as a client.Don’t panic Git is fun, powerful and it is the future.

Wait.. What? how did this happen

Slide 6

Page 7: Introduction to git administration

Subversion & Git Presentation

DVCS– Learn the difference

Users– Training– Indulging the Git promoter(s)

Many solutions to common problems– Authentication– Workflows– Multiple available UIs

Cleaning up after user mistakes

What am I in for?

Slide 7

Page 8: Introduction to git administration

Subversion & Git Presentation

1. RTFM http://git-scm.com/book2. Now that you read the Git book, go thru these

tutorials 3. Watch these videos - Google Tech Talks 

Linus Torvalds on git Randal Schwartz on Git 

4. RTFW https://git.wiki.kernel.org/index.php/Main_Page

5. Create a repo and start playing!

How I learned Git

Slide 8

Page 9: Introduction to git administration

Subversion & Git Presentation

Tutorialshttp://try.github.io/levels/1/challenges/1 Code Schoolhttps://www.atlassian.com/git/tutorial/git-basics Atlassian's Git tutorialhttp://gitready.com/ Git Readyhttps://www.kernel.org/pub/software/scm/git/docs/everyday.html Everyday GIT With 20 Commands Or So

Videos - Google Tech Talkshttp://www.youtube.com/watch?v=4XpnKHJAok8 Linus Torvalds http://www.youtube.com/watch?v=8dhZ9BXQgc4 Randal Schwartz

Wikihttps://git.wiki.kernel.org/index.php/GitCommunity|Git Community Wiki

Resources

Slide 9

Page 10: Introduction to git administration

Git Overview

Subversion & Git Presentation Slide 10

Page 11: Introduction to git administration

When coming from another SCM system to Git you need to shift how you think about how version control works.

In a more classic SCM you think of it as a system that versions files in a tree or directory structure.

Git is better thought of as a system that versions trees of files.

Biggest Obstacle

Page 12: Introduction to git administration

Subversion & Git Presentation

Stores whole copies of the repo– No file deltas– Entire tree is captured at each commit not just the files

that changed, a snapshot of the repo

Branches and tags– Are pointers to commits– Very fast and light weight

How Git Works

Slide 12

Page 13: Introduction to git administration

Subversion & Git Presentation

Git is:– Powerful – Complex– Fast (local)– worthy contender to replace many commercial tools– the solution you are looking for

Object Storage– Blobs– SHA1s or hashes– Trees

Perl like syntax– ^ $ ~ …

Not Scared yet?

Slide 13

Page 14: Introduction to git administration

Workflows

Page 15: Introduction to git administration

Centralized– Central repository

Feature Branch– Central repository + branching per features

Gitflow– Branches per features, releases and bug fixes

Forking– Distributed workflow

Workflows

Page 16: Introduction to git administration

Uses a central repository – single point-of-entry for all changes– Everyone clones from the central repo– Everyone pull/pushes from the same repo

Benefits– SCM Admin can put controls/triggers on the central repo– Security can be setup using tools like

• Stash• Gitolite • Gitosis

– SCM Builds and Deploys can be maintained from a clone of the central repo.

Centralized

Page 17: Introduction to git administration

Subversion & Git Presentation

Development of features in isolated branches– Allows features to be developed independently

As a feature is finished it is merged to the master branch

Feature Branch

Slide 17

Page 18: Introduction to git administration

Subversion & Git Presentation

Branches are focused around releasesBranches are also used for – Release– Integration or Test– Features

Strict rules on how and when branches interact

Gitflow

Slide 18

Page 19: Introduction to git administration

Subversion & Git Presentation

Repos are forked per developer– Developers work in isolation

One Repo is declared as the Official Repo– A Project Maintainer integrates the Repos– Developers sync with the Official Repo

Forking

Slide 19

Page 20: Introduction to git administration

Common Admin Tasks

Page 21: Introduction to git administration

What to Migrate? Snapshot in time or all history?– Push for converting a snapshot in time– If that fails, then try for a few key slices– Arguments

• Why burden the new repo with all the history• Populating new workspaces will take longer• Leave old SCM system in a locked down state for reference

– Refactoring• Always a good time to refactor when switching SCM system• Can cause headaches if under deadlines

– Builds• How dependent were you on the old SCM for builds

– Paths– Build tools (e.g. clearmake)– APIs, Libs

Migration Considerations

Page 22: Introduction to git administration

Subversion & Git Presentation

Client and Server conceptsUse a Client side hook for actions– Commit– Merge– Rebase

Server Hooks– Notification– Rejecting Pushes

Hooks need to be copied to the repos– Hooks are not part of cloning– Hooks do not get updated with pull/pushes

In general, use hooks in Git to encourage workflow or for notifications. Do not rely on them to enforce security

Hooks

Slide 22

Page 23: Introduction to git administration

Subversion & Git Presentation

Be Clever– There is no one way to provide Security– There is no single definition of Security

SSH keysGit Repository Management– Stash– Gitolite– Github

Triggers

Security

Slide 23

Page 24: Introduction to git administration

Subversion & Git Presentation

Sometimes a user removed something they didn’t mean to.The following commands are your friends when trying to figure out what to restore and from where.– Git log– Git relog– Git reset– Git update-ref

Repos for backups– Create clones on a safe network disk– Pull to them once a day (or once a week)– Use them to recover files or as a reference

Recovering files

Slide 24

Page 25: Introduction to git administration

Stories from the trenches

Page 26: Introduction to git administration

Builds failed after migrating a project from ClearCase to Git– Dev group certain the migration to Git had failed– Build depended on a large number of sub directories to

exist– Git does not add empty directories

• It needs a blob to point to a directory for the directory to exist.

– Solution was to initially add the missing directories • Created .temp files in each empty dir• This creates a blob and the directory is added to Git

– Long term solution • Encourage them to fix their build Ant/Make files.

Empty Directories

Page 27: Introduction to git administration

Subversion & Git Presentation

A user added multiple large files to his repo– Then committed them and pushed them to the central repo

User removed them with ‘git rm –rf’Why is this bad?– Clone commands went from seconds to 20 minutes

Why?– Git didn’t remove the large files from the initial commit– Clone copies the entire repo locally, those files while no

longer visible are still copied

Solution– Git filter-branch– Git gc– Git prune

Slow Clones

Slide 27

Page 28: Introduction to git administration

Subversion & Git Presentation

Client Requirements– Contractors limited to sub dirs.– All files in a single Repo.

Git by design– Does not preserve directory permissions– Hooks run before or after a Git command– Submodules don’t offer additional protections

• Also broke the client single repo requirement

Directory Isolation

Slide 28

Page 29: Introduction to git administration

Subversion & Git Presentation

Client workflow depended on TagsGit Tags are not shared by default– Tags need to be explicitly;

• Pushed to the remote• Pulled locally

Solutions– Reevaluate Workflow– Share pull command with Tag name– Share Hash

Universal Tags

Slide 29

Page 30: Introduction to git administration

Subversion & Git Presentation

Client wanted to control who could create a local repo– Git is not designed to do this

You can limit who can clone from a central Repo– Stash/Gitolite– SSH Keys

Once a Repo is cloned– Nothing is stopping the user from cloning it again– They can allow others to clone

Solution– Lock down who can push back to the central Repo

Controlling local repos

Slide 30

Page 31: Introduction to git administration

Subversion & Git Presentation

Client wants to Clone one subdir of a Repo– Build requires entire Repo– Deploy requires one sub dir– Build happens weeks before the deploy– Deploy wants a fresh Repo

• Just build results and deployment script

Solution– Submodules

Partial Clone

Slide 31