USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

Similar documents
GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

GETTING TO KNOW GIT: PART II JUSTIN ELLIOTT PENN STATE UNIVERSITY

Git! Fundamentals. IT Pro Roundtable! June 17, 2014!! Justin Elliott! ITS / TLT! Classroom and Lab Computing!! Michael Potter!

Git for Newbies. ComMouse Dongyue Studio

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Git. Presenter: Haotao (Eric) Lai Contact:

Working in Teams CS 520 Theory and Practice of Software Engineering Fall 2018

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 17, 2018

What is git? Distributed Version Control System (VCS); Created by Linus Torvalds, to help with Linux development;

Version Control. Version Control

Beyond git add/commit/push

Topics covered. Introduction to Git Git workflows Git key concepts Hands on session Branching models. Git 2

Git better. Collaborative project management using Git and GitHub. Matteo Sostero March 13, Sant Anna School of Advanced Studies

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

Software Project (Lecture 4): Git & Github

Software Development I

Managing Network Configurations with Git and GitLab

Revision Control. An Introduction Using Git 1/15

git-flow Documentation

Git Basi, workflow e concetti avanzati (pt2)

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani -

Fundamentals of Git 1

Version Control System - Git. zswu


AIS Grid School 2015

Windows. Everywhere else

GUIDE TO MAKE A REAL CONTRIBUTION TO AN OPEN SOURCE PROJECT 1. 1

Tutorial: Getting Started with Git. Introduction to version control Benefits of using Git Basic commands Workflow

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Assumptions. GIT Commands. OS Commands

git Version: 2.0b Merge combines trees, and checks out the result Pull does a fetch, then a merge If you only can remember one command:

Version Control: Gitting Started

Getting started with GitHub

CS 320 Introduction to Software Engineering Spring February 06, 2017

Git Workflows. Sylvain Bouveret, Grégory Mounié, Matthieu Moy

Introduction to distributed version control with git

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

Lab Objective. Lab Assignment. Downloads and Installation

Versioning with git. Moritz August Git/Bash/Python-Course for MPE. Moritz August Versioning with Git

Software Revision Control for MASS. Git Installation / Configuration / Use

Git Tutorial. André Sailer. ILD Technical Meeting April 24, 2017 CERN-EP-LCD. ILD Technical Meeting, Apr 24, 2017 A. Sailer: Git Tutorial 1/36

Lab 01 How to Survive & Introduction to Git. Web Programming DataLab, CS, NTHU

Algorithm Engineering

CESSDA Expert Seminar 13 & 14 September 2016 Prague, Czech Republic

Git: Distributed Version Control

Version Control. Version Control

Version Control with GIT

Revision Control and GIT

Introduction to Git. Database Systems DataLab, CS, NTHU Spring, 2018

Git for Subversion users

Index. Alias syntax, 31 Author and commit attributes, 334

Git tutorial. Katie Osterried C2SM. October 22, 2015

Continuous integration & continuous delivery. COSC345 Software Engineering

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

Introduction to Version Control with Git

The Old World. Have you ever had to collaborate on a project by

Git Resolve Conflict Using Mine Command Line

License. Introduction to Version Control with Git. Local Version Control Systems. Why Use Version Control?

Online Remote Repositories

Git: Distributed Version Control

Revision control Advanced git

About SJTUG. SJTU *nix User Group SJTU Joyful Techie User Group

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Introduction to Version Control

Improving Your Life With Git

Submitting your Work using GIT

Using git to download and update BOUT++

CS314 Software Engineering Configuration Management

GIT : BEST PRACTICES GUIDE BY ERIC PIDOUX DOWNLOAD EBOOK : GIT : BEST PRACTICES GUIDE BY ERIC PIDOUX PDF

Getting the files for the first time...2. Making Changes, Commiting them and Pull Requests:...5. Update your repository from the upstream master...

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 11, 2017

Outline The three W s Overview of gits structure Using git Final stuff. Git. A fast distributed revision control system

Bitte decken Sie die schraffierte Fläche mit einem Bild ab. Please cover the shaded area with a picture. (24,4 x 7,6 cm)

VCS VERSION CONTROL SYSTEMS

Push up your code next generation version control with (E)Git

Git & Github Fundamental by Rajesh Kumar.

Git. A fast distributed revision control system. Nils Moschüring PhD Student (LMU)

Object Oriented Programming. Week 1 Part 2 Git and egit

Table of Contents. Concepts

Version control. with git and GitHub. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Git Introduction CS 400. February 11, 2018

Using Git to Manage Source RTL

ZIP Code to Legislative District Matching via Cicero. Aaron Dennis

Version control system (VCS)

L Modeling and Simulating Social Systems with MATLAB

GIT TO DA REPO! VERSION CONTROL, GITLAB, AND ISU

Revision control. INF5750/ Lecture 2 (Part I)

MOOSE-Based Application Development on GitLab

A L A TEX-oriented intro to Git

GIT VERSION CONTROL TUTORIAL. William Wu 2014 October 7

E, F. deleteall command, 352 directory structure, 350 export_data method, 353 inline_data method, 353 print_export method, 351 target directory, 351

Software Revision Control for MASS. Git Basics, Best Practices

GIT. CS 490MT/5555, Spring 2017, Yongjie Zheng

CS 390 Software Engineering Lecture 5 More Git

CSE 391 Lecture 9. Version control with Git

A BASIC UNDERSTANDING OF VERSION CONTROL

Intro to Github. Jessica Young

Version control. what is version control? setting up Git simple command-line usage Git basics

Git, the magical version control

Transcription:

USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

AGENDA Version control overview Introduction and basics of Git Advanced Git features Collaboration Automation

VERSION CONTROL

WHAT IS IT? Manages changes and versions of files Also known as: Source Code Management (SCM) Version Control System (VCS) GitHub is a hosting service that uses Git

WHY USE IT? Reduces risk and enables you to experiment with code Agility Flexible workflows Quicker deployments Automate updates

WHY USE IT? Helps with documentation Collaboration with others Contributing to open source projects Modifying a project for your own use

GIT INTRODUCTION

WHY GIT? The current de facto standard for source code management Easy to learn, quick to start! Very powerful and extensive

GIT OVERVIEW Extremely fast Excellent data integrity Git checksums everything (SHA-1)

GIT OVERVIEW Distributed All clients have the full repo Backups are everywhere Local repo updated before remotes When available, push updates to remote

GIT TERMINOLOGY Repository Local Remote Working Directory Commit

GIT INSTALLATION & CONFIGURATION

H O W T O I N S TA L L G I T Embedded with many Git GUI Apps Included with XCode Download from http://git-scm.com OS X: Terminal.app Windows: Git Bash Linux: Terminal OS X: MacPorts and HomeBrew

GIT CLIENT APPS http://git-scm.com/downloads/guis GitHub Desktop https://desktop.github.com SourceTree https://www.sourcetreeapp.com

REVIEWING DIFFS Very easy to view with GitHub Desktop and Web External diff apps FileMerge Kaleidoscope

GITHUB DESKTOP Simplifies the complex Git tasks Integrates well with GitHub hosting service Easy to start with Limited feature set (by design)

DEMO: GITHUB CONFIG

CONFIGURING GIT ON THE CLI Git GUI clients handle it for you, or for the CLI fans $ git config Contains items such as name, email, editor, diff tool Critical for collaboration

DEMO: GIT CONFIG CLI https://asciinema.org/a/anjsg2tmlwul6j3ahizgl98ie

FUNDAMENTALS

REPO FILE CLASSIFICATIONS Tracked Ignored Untracked

TRACKED FILE STATES Modified Staged GitHub Desktop shows as checkboxes Committed

CREATE A REPO Create new empty project repository Working Directory

ADD FILES TO THE REPO Add (stage) files for the next commit Working Directory add Staging Area

COMMIT FILES TO REPO Save staged files to the project repository Working Directory add Staging Area commit Repository

COMMITS Saves file changes to the repo Each commit should encapsulate a single fix* Commit often - You will thank yourself later! Or else Larger changes are much harder to pick apart and revert back to.

IGNORING FILES / DIRECTORIES Why? What? How? Scope Single Project Repo All Repos ( Global ~/.gitignore_global file ) Recommended to create ignore file as first step

COMMIT HISTORY LOGS Review history of commits to repo Documents changes over time Extremely helpful for your future self and others

DEMO Create repo Modify same tracked file Create files View diff of file changes Show status Commit the file Ignore file(s) Review history log Commit git ignore file Revert to previous commit Initial commit of file Review history log

BRANCHES

BRANCHES Provide separate paths of code development When should they be used? Others to help test before merged to master master is the default branch Great for vetting major changes, for others to review Many workflow methods out there (ie, GitFlow)

BRANCH WALK THROUGH First Commit M1

BRANCH WALK THROUGH M1 B1 New Branch

BRANCH WALK THROUGH M1 B1 B2 Second Branch Commit

BRANCH WALK THROUGH M1 B1 B2 B3 Third Branch Commit

BRANCH WALK THROUGH M1 B1 B2 B3 B4 Fourth Branch Commit

BRANCH WALK THROUGH Merge Branch To Master M1 M2 B1 B2 B3 B4 (Branch Deleted After Merge)

GIT'S "HEAD" REFERENCE Reference pointer to a commit Detached HEAD warning What does it mean? When does this occur? What should I do? Have code changes? Branch!

BRANCH WORKFLOWS GitHub Flow Atlassian s List Centralized Feature Git Flow Forking

REMOTES

REMOTES Local repo on your client only Remote is a Git host to push to You clone from remote(s) ie. GitHub, BitBucket First remote is called origin Avoid changing the remote name, some GUI Apps look for it

REMOTE REPOS Network Protocols HTTPS SSH (Keys) Git Protocol (daemon)

SELF-HOSTED REPO SERVICES SSH Enable SSH, create bare repository on server % git init --bare --shared Atlassian Stash Enterprise GitHub GitLab

HOSTED REPO SERVICES GitHub, BitBucket SourceRepo, Assembla GitLab git.psu.edu for Penn Staters (runs on GitLab) And many more

GIT WORKFLOW STAGES Working Directory add Staging Area commit Repository pull push Remote

CLONING Copies repo from remote Repo includes entire project

PUSHING Saves commits to remote server Pushes active branch that you re on

FETCHING Updates repo status of remote Local repo files are not changed Always fetch or pull before pushing to remotes!

REMOTES - DO'S AND DON'TS Do... Always fetch or pull before making changes Don't... Otherwise you will need to merge or rebase your changes Make changes to local repo before fetching/pulling, or else create a new branch first OR stash the files first

REMOTES DEMO Add local repo to GitHub Desktop Publish to GitHub View new remote host via git remote -vv View tracking branch(es) via git branch -vv Local branches track remote branches Commit first to local, then push to GitHub Create README.md file on GitHub, Pull

COLLABORATION

ETIQUETTE Pull Request vs. Feature Requests Read the project's docs and guidelines first Start with simple changes to learn processes Avoid pull requests on pull requests Instead, provide feedback to author of pull for additional fixes or suggestions

ETIQUETTE Commit Messages Keep them small, clear and descriptive Remember others need to understand them Stick to the project's coding styles and conventions Follow or establish team decided branch workflow Be nice!

CREATING A PULL REQUEST Their Remote Repo Contributor fork Your Remote Repo merge push clone/pull Local Repository commit Pull Request Working Copy Discussion

GITHUB PULL REQUEST

RECEIVING A PULL REQUEST Discuss and gather feedback

RECEIVING A PULL REQUEST Squash & merge or Merge commit

RECEIVING A PULL REQUEST Checkout and test

AUTOMATION

INTEGRATIONS Automatic emails Push notifications Slack Channels, IRC, Twitter, HipChat, etc. Methods WebHooks Agents / Runners Polling

AUTOMATION TOOLS Scripts launchd, cron to automate git pulls AutoPkgr schedule for autopkg recipe repos Continuous Integration Jenkins, Atlassian Bamboo, GitLab Travis CI

WEBHOOKS Receive event notifications between multiple systems commit, push (tag or branch), releases, issues, documentation updates, forks, etc. Useful for updating, notifying, building, testing, backing up, deploying

AUTOMATION IDEAS Auto update servers (Web, etc.) Revert to previous commit Example Agent/Runner runs script after repo receives commit Automated testing, build and test products/recipes

AUTOMATED WORKFLOWS Update server content from master branch Auto pull ready for production versions Track changes made on servers, switches.git folder security issue - be aware

CLC CASE STUDY GitLab GitHub autopkg Jenkins Slack BigFix

CLC CASE STUDY Lessons Learned Use the tool that works best Keep it simple and robust Lots of notifications, categorized and specific Working with internal and external collaborators Leverage the features of Git - commits, events, builds

SUMMARY

LESSONS LEARNED Start small Pick just one project to manage with Git Use remotes when ready GitHub, BitBucket Your own SSH host

LESSONS LEARNED Write good commit messages There will be a time when you need to search your commit messages and it will really help you out! Be nice to your future self. Where / when / how did I fix that issue? What s for the release notes?

LESSONS LEARNED Keep it simple Don't be afraid to experiment Automation and integrations are powerful Use them after you're comfortable with the basics

RESOURCES AND TRAINING http://bit.ly/psumac-git-cs Official Git Site http://git-scm.com Git Cheat Sheets Git Pro Book bit.ly/psumac-nice-pulls

RESOURCES AND TRAINING http://try.github.com - learn Git in 15 minutes! http://atlassian.com/git http://bit.ly/psumac-git-wf O Reilly McCullough and Berglund on Mastering Git

Q & A Justin Elliott jelliott [at] psu.edu @justindelliott Matt Hansen hansen.m [at] psu.edu @hansen_m Feedback: https://bit.ly/psumac2016-91