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

Similar documents
GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

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

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

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

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

Software Development I

Software Project (Lecture 4): Git & Github

Revision Control. An Introduction Using Git 1/15

Git. Presenter: Haotao (Eric) Lai Contact:

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

Fundamentals of Git 1

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

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

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

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

Getting started with GitHub

Git for Newbies. ComMouse Dongyue Studio

Using git to download and update BOUT++

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

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Version Control: Gitting Started

What is Git? What is Git? Version Control. Barry Grant

Using Git to Manage Source RTL

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

Version control with Git.

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

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

Laboratorio di Programmazione. Prof. Marco Bertini

Managing Network Configurations with Git and GitLab

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

LAB MANUAL GIT BY PRATIK JAIN. To start with git bash, we need to authenticate ourselves so that for every commit, git can use this information.

Git for Version Control

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

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

Beyond git add/commit/push

Introduction to distributed version control with git

Git: Distributed Version Control

Git & Github Fundamental by Rajesh Kumar.

Git: Distributed Version Control

Lab Exercise Git: A distributed version control system

A quick (and maybe practical) guide to Git and version control. By Jay Johnson

Git for Subversion users

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

EECS 470 Lab 4. Version Control System. Friday, 31 st January, 2014

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

Git Source Control: For the Rest of Us. Nolan Erck

Git Basi, workflow e concetti avanzati (pt2)

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

Introduction to Version Control

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

AIS Grid School 2015

Computer Science Design I Version Control with Git

Barry Grant

Introduction to Git and Github

GIT VERSION CONTROL TUTORIAL. William Wu 2014 October 7

Git version control with Eclipse (EGit) Tutorial

Introduction to Version Control using Git

A BASIC UNDERSTANDING OF VERSION CONTROL

Project Management. Overview

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

Revision control. INF5750/ Lecture 2 (Part I)

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

CSE 391 Lecture 9. Version control with Git

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

Introduction to Version Control with Git

Version Control. Version Control

How to be a 1337 h4ck3r: Git + Linux

Git, the magical version control

Online Remote Repositories

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

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

2/8/18. Overview. Project Management. The First Law. What is Project Management? What Are These Changes? Software Configuration Management (SCM)

Revision Control and GIT

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

Submitting your Work using GIT

Lab Objective. Lab Assignment. Downloads and Installation

Version control system (VCS)

How to be a git. Dominic Mitchell

A Brief Introduction to Git. Sylverie Herbert (based on slides by Hautahi Kingi)

Version Control with Git ME 461 Fall 2018

Windows. Everywhere else

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

How to set up SQL Source Control The short guide for evaluators

Version Control with GIT

School of Computing Science Gitlab Platform - User Notes

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

FEEG Applied Programming 3 - Version Control and Git II

Git Resolve Conflict Using Mine Command Line

Version Control Systems (Part 1)


Version Control System - Git. zswu

Algorithm Engineering

S18 Modern Version Control with Git

Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

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

Improving Your Life With Git

Salvatore Rinzivillo VISUAL ANALYTICS

Having Fun with Social Coding. Sean Handley. February 25, 2010

LPF Training Handbook!

Git. A Distributed Version Control System. Carlos García Campos

Transcription:

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

What is Version Control? Version Control System (VCS)! Source Code Management (SCM)! Management of changes to documents like source code, scripts, text files! Provides the ability to check documents in and out of a repository 2

Why Use It? It s totally liberating!! Removes the risk of updating your code, encourages you to experiment! It will greatly enhance your ability to be agile and move quickly with development! Quick access to snapshot versions of your documents / source code 3

Why Use It? Can easily collaborate with multiple developers on different project! Starting to become a standard for new open source web projects! Git Flow promotes good dev, test, live practices.! Very easy to track, deploy, revert code 4

Git: A Great SCM Tool Easy to learn, very powerful! Distributed (DVCS)! Clients have the full repo! Extremely fast performance! Excellent data integrity! Git checksums everything in the repo (sha1)! Easy branching. No, really. Sorry SVN! 5

Git versus Subversion Lightning Fast, much faster checkouts! Merging is much easier! Distributed versus centralized! No need for constant network access! Easier to ignore files and edit other properties! Moving files and folders in Git is much easier to do than in Subversion 6

Basic Git Terminology Repository! Working Directory! Clone! Commit 7

Basic Git Terminology Branch! Tag! Remotes (Origin)! HEAD (Refers to Branch or Commit) 8

Git File Classifications Tracked -- already in the repository! Ignored -- can exist, but git ignores it! Untracked -- What s not tracked or ignored 9

Git File States Modified -- changed but not yet committed! Staged -- marked a modified file to go into next commit! Committed -- safely stored in the repository 10

Git File Status Lifecycle 11

Git Workflow Working Directory Staging Area Repository 12

Installation Download installer from http://git-scm.com! Windows! Git Bash Is Recommended! OS X! Use Terminal.app! Embedded with many GUI clients 13

Initial Git Config Set your user name and email address via git config command, like this: 14

Beware Line Endings End of line characters differ based on OS! Windows uses two invisible characters! CR (Carriage Return)! LF (Line Feed)! OS X and Linux use one invisible character! LF (Line Feed)! Embrace the native line endings for each platform, everyone will be much happier. 15

Line Ending Modes core.autocrlf true! Recommended for cross platform projects from Windows clients! core.autocrlf input! Recommended for cross platform projects from OS X / Linux / Unix clients! core.autocrlf false! Recommended only for single platform projects 16

Line Endings on Windows Enable auto convert to LF on Windows by using git config to set core.autocrlf to true: 17

Line Endings on OS X On OS X, enable auto convert CRLF to LF: 18

Git Attributes Useful for configuring and enforcing the type of line endings files get when commited to the repository! Specified based on filename extensions in the.gitattributes file! Still need to configure the client s auto.crlf setting so their OS is happy with endings 19

Git Attributes Example In the root of the Git repo folder, the.gitattributes file: 20

Cloning a Repository The process of copying an existing Git repository to your computer! Cloning a repo includes the entire file history changes and commit messages! Git Clone Command example:! $ git clone https://git.psu.edu/jde6/project.git 21

Cloning a Repository 22

Create A New Repository From the command line:! $ git init reponame.git! Creates special.git directory within the project directory 23

Create A New Repository 24

Status Of Files How do I know what has changed?! $ git status! Status reports different states! Untracked! Modified! Staged 25

Status Of Files 26

Adding Files To The Repo Added files are staged! Why stage anything at all?! How do I add modified items?! cd to reponame.git directory! Add a file! $ git add -v FileName.php! Add all new files! $ git add -v. 27

Adding Files To The Repo 28

Committing Changes This process saves the changes to the repository.! Commit Often - You will thank yourself later!! Or else. larger changes are much harder to pick apart and revert back.! Get those Mini Victories of progress! $ git commit -m Commit Message! Each commit should encapsulate a single fix* 29

Committing Changes 30

Stashing Very useful for when you re not ready to commit the changes to the repo yet.! Saves your changes to the local Git repo and does not commit them.! $ git help stash 31

Differences Commits are all about what is different!! Viewing the differences! At the command line! $ git diff FileName! In GUI Apps! Kaleidoscope, FileMerge, Changes.app, etc. 32

Differences 33

Ignoring Files Use the.gitignore file to add filenames and paths to ignore and exclude from the repo! Specify names of directories or files! Use wildcards for matching! Temp Cache files, file extensions, etc.! *.mp3, *.tmp, SensitiveData.xlsx, etc. 34

Ignoring Files 35

Branches Master (Main) branch is the default! Separate lines of development! Ex: Master, Hot Fix, Development, Feature! Merging of branches is where Git excels! Git Flow is a popular branching model 36

Tags Useful for marking a specific commit! Example: Mark commit that is for major version change! 1.0.1! 1.0.2! Also useful for regression testing with the git bisect command 37

Git GUI Clients GitHub! OS X! Windows! Mobile 38

Git GUI Clients SourceTree! OS X! Windows! Tower! OS X! SmartGit, GitBox, TortoiseGit 39

SourceTree Free! Excellent GUI client for OS X and Windows! Connects to Git Hosting Services! git.psu.edu! Via SSH, HTTPS! GitHub, Bitbucket, Google Code, etc. 40

Remote Repos Local Versus Remote (Hosted) Repos! Push changes to local first, then push all to remote repo(s)! Cloning from a remote host! Branching from a remote/local host! Read/Write versus Read-Only Accounts 41

Remote Repos Network Based! HTTPS! SSH! Git Protocol (daemon) 42

Remote Repos 3rd Party! git.psu.edu! GitHub, BitBucket, Google Code! CodeSpaces, SourceRepo! Assembla, Gitorious 43

PSU GitLab Web-based hosting service for Git http://git.psu.edu! Internally hosted by VMhosting a service of ITS SaS! Available to anyone with a Penn State Access Account! Currently doesn t support FOPS accounts 44

GitLab Cool Features Free public and private repos! Issue tracking! Groups! Commit history graph reporting! Project wikis 45

Demo 46

Git Flow Workflow for managing branches! Five different branch types! feature branches! develop! release branches! hotfixes! master 47

Git Flow 48

Feature Branches Where the code is made! Examples of feature branch:! Responsive Calendar, Homepage Twitter Widget, New Article Field! Feature branch could have multiple branches off of it 49

Develop Completed features are tested! Multiple features can be tested to see how they impact each other! Can be linked to a development server, often named Integration Server 50

Release Branches Collection of features that passed testing in the develop branch! Production ready code ready to be merged into master! Could be linked to a QA server 51

Hotfix The Oh No branch! Branched directly off of master! Once fixed, it s merged up to master and down to develop branch 52

Master The project s live code! Only for merging 53

SourceTree Git Flow 54

Lessons Learned Branch Names! No White Space (tabs, spaces)! Supports Hierarchical Names*! bug/pr-1023, bug/pr-17! $ git show-branch bug/*! Tags! Use annotated most of the time 55

Lessons Learned Take the time to 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? 56

Start small! Lessons Learned Pick one project to implement Git! Use just the develop and master branches at first, add additional branches as you get more comfortable! Incorporate GitLab features into your project management workflow! wikis, issues, comments 57

Lessons Learned Using a VCS/SCM makes you more mobile and code tested on more environments makes that project more robust.! Commenting helps to clarify your comments, design flow, and for code review! Git is a fantastic tool for collaborative projects 58

Resources and Training Official Git Site! http://git-scm.com! http://git-scm.com/book (Pro Git Book)! lynda.psu.edu Fundamentals of Software Version Control Git Essential Training 59

Resources and Training http://try.github.com! http://atlassian.com/git! O Reilly! McCullough and Berglund on Mastering Git 60

Questions? Yammer Groups! git.psu.edu! PSU Software Developer Working Group! Justin Elliott jde6@psu.edu! Michael Potter mgp140@psu.edu 61