git Tutorial Nicola Chiapolini Physik-Institut University of Zurich January 26, 2015

Similar documents
git Tutorial Nicola Chiapolini Physik-Institut University of Zurich June 8, 2015

git Tutorial Nicola Chiapolini University of St. Gallen September 12, 2017

git Tutorial Nicola Chiapolini Physik-Institut University of Zurich March 16, 2015

Git it Together! Version Management for Research Projects

Version Control GIT Overview Local GIT Branching Remote GIT Server Extras. GIT for Beginners. Anthony Baire. Université de Rennes 1.

Best Practices. Nicola Chiapolini. Physik-Institut University of Zurich. June 8, 2015

GIS Software. Evolution of GIS Software

Lecture Notes on Numerical Solutions of Differential Equations. Instructor: Prof. Dongwook Lee

Science Analysis Tools Design

Finite Math Section 6_1 Solutions and Hints

( ) and D( x) have been written out in

Arcgis Tutorial Manual READ ONLINE

Comprehending How Merge Conflicts Developed in an Open Source Software Project

Running jobs on the CS research cluster

Using SkyTools to log Texas 45 list objects

FIELD SPECTROMETER QUICK-START GUIDE FOR FIELD DATA COLLECTION (LAST UPDATED 23MAR2011)

PyMISP - (ab)using MISP API with PyMISP MISP - Malware Information Sharing Platform & Threat Sharing

Continuous Performance Testing Shopware Developer Conference. Kore Nordmann 08. June 2013

Mnova Software for Analyzing Reaction Monitoring NMR Spectra

Sapienza universita di Roma Dipartimento di Informatica e Sistemistica. User guide WSCE-Lite Web Service Composition Engine v 0.1.

EXERCISE 12: IMPORTING LIDAR DATA INTO ARCGIS AND USING SPATIAL ANALYST TO MODEL FOREST STRUCTURE

(latitudinal form of solar radiation. The part in parentheses is the 2 nd Legendre polynomial, a polynomial that integrates to zero over the sphere)

Introduction to ArcGIS Server Development

Physics E-1ax, Fall 2014 Experiment 3. Experiment 3: Force. 2. Find your center of mass by balancing yourself on two force plates.

Nuclear Physics Fundamental and Application Prof. H. C. Verma Department of Physics Indian Institute of Technology, Kanpur

WeatherHawk Weather Station Protocol

How to Make or Plot a Graph or Chart in Excel

ICM-Chemist How-To Guide. Version 3.6-1g Last Updated 12/01/2009

M o n i t o r i n g O c e a n C o l o u r P y t h o n p r o c e d u r e f o r d o w n l o a d

Watershed Modeling Orange County Hydrology Using GIS Data

The Abinit project. Coding is based on modern software engineering principles

Lab 1: Numerical Solution of Laplace s Equation

Mathematical Logic Part One

ArcGIS Pro: Essential Workflows STUDENT EDITION

CHEOPS Feasibility Checker Guidelines

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Creating Empirical Calibrations

Quantification of JEOL XPS Spectra from SpecSurf

VCCS Geospatial Institute 2011

AMS 132: Discussion Section 2

The World Bank and the Open Geospatial Web. Chris Holmes

Watershed Modeling With DEMs

Quick Start Guide New Mountain Visit our Website to Register Your Copy (weatherview32.com)

Deep-dive into PyMISP MISP - Malware Information Sharing Platform & Threat Sharing

Presenting Tree Inventory. Tomislav Sapic GIS Technologist Faculty of Natural Resources Management Lakehead University

Introduction to Portal for ArcGIS

Senior astrophysics Lab 2: Evolution of a 1 M star

VCell Tutorial. Building a Rule-Based Model

Web GIS Deployment for Administrators. Vanessa Ramirez Solution Engineer, Natural Resources, Esri

Geodatabase Best Practices. Dave Crawford Erik Hoel

MapOSMatic, free city maps for everyone!

/home/thierry/columbia/msongsdb/tutorials/tutorial4/tutorial4.py January 25,

Athena Visual Software, Inc. 1

The Quantizing functions

CSE 241 Class 1. Jeremy Buhler. August 24,

SDS developer guide. Develop distributed and parallel applications in Java. Nathanaël Cottin. version

Yes, the Library will be accessible via the new PULSE and the existing desktop version of PULSE.

Using GIS Online for tracking development of roadway construction plans. Tom Cox Viraj Perera

Gis 10 Training Manual

Foundations of

CS Homework 3. October 15, 2009

Apex Python library. Release 1.0.1

Incorporating ArcGIS Pro in your Curriculum

BASIC TECHNOLOGY Pre K starts and shuts down computer, monitor, and printer E E D D P P P P P P P P P P

Creating Questions in Word Importing Exporting Respondus 4.0. Importing Respondus 4.0 Formatting Questions

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

ArcGIS Pro Q&A Session. NWGIS Conference, October 11, 2017 With John Sharrard, Esri GIS Solutions Engineer

ST-Links. SpatialKit. Version 3.0.x. For ArcMap. ArcMap Extension for Directly Connecting to Spatial Databases. ST-Links Corporation.

Lab 1: Handout GULP: an Empirical energy code

EARTHQUAKE ANALYSIS with SAP2000

Subject: Cycle Modification on the ABI 3900 DNA Synthesizer using software v1.2

SHOCK AND VIBRATION RESPONSE SPECTRA COURSE Unit 6B. Notes on the Fourier Transform Magnitude

PAID INVOICE TAX REPORT

SuperCELL Data Programmer and ACTiSys IR Programmer User s Guide

An ESRI Technical Paper June 2007 An Overview of Distributing Data with Geodatabases

Web GIS Administration: Tips and Tricks

Sign Changes By Bart Hopkins Jr. READ ONLINE

VEGAS DIAGNOSTICS TOOLS

Collaborative Forecasts Implementation Guide

Tile-Based Geospatial Information Systems

Lab 6: Linear Algebra

LandscapeDNDC: Getting started

Lecture 5b: Starting Matlab

Troubleshooting Replication and Geodata Service Issues

TitriSoft 2.5. Content

Appendix 4 Weather. Weather Providers

Cantera / Stancan Primer

High-Performance Scientific Computing

ISSP User Guide CY3207ISSP. Revision C

NCS. New Control System for the 30m Telescope. TBD. 2005

LAB 3: WORK AND ENERGY

MITOCW watch?v=dztkqqy2jn4

v Prerequisite Tutorials GSSHA WMS Basics Watershed Delineation using DEMs and 2D Grid Generation Time minutes

Working with ArcGIS: Classification

Using a GIS to Calculate Area of Occupancy. Part 1: Creating a Shapefile Grid

Investigating Factors that Influence Climate

Paper The syntax of the FILENAME is:

Geoprocessing Tools at ArcGIS 9.2 Desktop

An area chart emphasizes the trend of each value over time. An area chart also shows the relationship of parts to a whole.

Optical Pumping of Rubidium

Transcription:

Nicola Chiapolini, January 26, 2015 1 / 36 git Tutorial Nicola Chiapolini Physik-Institut University of Zurich January 26, 2015 Based on talk by Emanuele Olivetti https://github.com/emanuele/introduction_to_git.git This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 License.

Nicola Chiapolini, January 26, 2015 2 / 36 Motivation to use Version Control Problem 1 Help! my code worked yesterday, but I can t recall what I changed. track modifications access old version Problem 2 We would like to work together, but we don t know how! concurrent editing merging development versions

Nicola Chiapolini, January 26, 2015 3 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 3 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 4 / 36 Survey: Version Control Q1: Have you heard about version control? Q2: Do you use a version control software (cvs, svn, hg, bzr, git)? Q3: How much experience do you have with git?

Nicola Chiapolini, January 26, 2015 4 / 36 Survey: Version Control Q1: Have you heard about version control? Q2: Do you use a version control software (cvs, svn, hg, bzr, git)? Q3: How much experience do you have with git?

Nicola Chiapolini, January 26, 2015 4 / 36 Survey: Version Control Q1: Have you heard about version control? Q2: Do you use a version control software (cvs, svn, hg, bzr, git)? Q3: How much experience do you have with git?

Nicola Chiapolini, January 26, 2015 5 / 36 Uses for git Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. Git Website checkpoints/backups/releases document developer effort collaboration across the globe for anything that s text code thesis/papers system config files (vcsh)...and everything else ( "gitify your life", git-annex )

Nicola Chiapolini, January 26, 2015 6 / 36 Version Control: Local Computer Checkout file Version Database Version 3 Version 2 Version 1 checkout working directory version database repository

Nicola Chiapolini, January 26, 2015 7 / 36 Version Control: Central Computer A Checkout file Server Version Database Version 3 Computer B Checkout file Version 2 Version 1

Nicola Chiapolini, January 26, 2015 8 / 36 Version Control: Distributed Computer A Checkout Version Database file Version 3 Version 2 Version 1 Computer B Checkout Version Database file Version 3 Server Version Database Version 3 Version 2 Version 1 Version 2 Version 1

Nicola Chiapolini, January 26, 2015 9 / 36 git: Help usage: git [OPTIONS] COMMAND [ARGS] The most commonly used git commands are: add Add file contents to the index commit Record changes to the repository diff Show changes between commits, commit and working tree, etc... git help <command> git help <concept> git status

Nicola Chiapolini, January 26, 2015 10 / 36 git: Introduce yourself git config --global user.name "Nicola Chiapolini" git config --global user.email "nchiapol@physik.uzh.ch"

Nicola Chiapolini, January 26, 2015 11 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 12 / 36 Single+Local git: Init git init Creates an empty git repository. Creates the git directory:.git/ working directory staging area does not change your files

Nicola Chiapolini, January 26, 2015 12 / 36 Single+Local git: Init git init Creates an empty git repository. Creates the git directory:.git/ working directory staging area does not change your files

Nicola Chiapolini, January 26, 2015 13 / 36 Single+Local git: Add git add file1 [file2...] Adds new files for next commit Adds content from working dir for next commit DOES NOT add info on file permissions other than exec/noexec DOES NOT add directories per se. working directory staging area git add

Nicola Chiapolini, January 26, 2015 14 / 36 Single+Local git: Commit git commit [-m "Commit message."] Records changes from the staging area to. working directory staging area git commit

Nicola Chiapolini, January 26, 2015 15 / 36 Single+Local git: Direct Commit git commit file1 file2 [-m "Commit message."] Records all changes of file1, file2 from working dir and staging area to. working directory staging area git commit <filename> git commit -a[m "Commit message."] Records all changes in working dir and staging area. Be Careful!

Nicola Chiapolini, January 26, 2015 16 / 36 Single+Local git: Diff git diff [filename...] Shows changes between working directory and staging area working directory staging area git diff

Nicola Chiapolini, January 26, 2015 17 / 36 Single+Local git: Diff Staged How do I see what is staged? git diff --staged shows differences between staging area and last commit. working directory staging area git diff --staged

Nicola Chiapolini, January 26, 2015 18 / 36 Single+Local git: Logs Shows details of the commits. git log [--oneline] working directory staging area git log

Nicola Chiapolini, January 26, 2015 19 / 36 Single+Local git: Graphic Logs GUI to browse the git repository. gitk / gitg

Nicola Chiapolini, January 26, 2015 20 / 36 Single+Local git: Changing Version git checkout <file commit> working directory staging area git checkout <file>

Nicola Chiapolini, January 26, 2015 20 / 36 Single+Local git: Changing Version git checkout <file commit> working directory staging area git checkout <commit>

Nicola Chiapolini, January 26, 2015 21 / 36 Single+Local git: (Re)move. Warning: whenever you want to remove, move or rename a tracked file use git: git rm <filename> git mv <oldname> <newname> Remember to commit these changes! git commit -m "File (re)moved."

Nicola Chiapolini, January 26, 2015 22 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 23 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 24 / 36 multi+remote/shared git: Setup Computer A Checkout Version Database file Version 3 Version 2 Version 1 Computer B Checkout Version Database file Version 3 Server Version Database Version 3 Version 2 Version 1 Version 2 Version 1

Nicola Chiapolini, January 26, 2015 25 / 36 multi+remote/shared git: Clone git clone <URL> Creates two local copies of the whole remote repository. Remote (Server) Version Database Hint git remote -v shows name and URL of the remote repository.

Nicola Chiapolini, January 26, 2015 25 / 36 multi+remote/shared git: Clone git clone <URL> Creates two local copies of the whole remote repository. Local (Computer A) Remote (Server) working directory staging area remote/ origin/ git clone <url> Checkout Version Database Version Database Hint git remote -v shows name and URL of the remote repository.

Nicola Chiapolini, January 26, 2015 26 / 36 multi+remote/shared git: Commands Local Remote working directory staging area remote/ origin/ git add git commit git push git fetch git checkout git merge

Nicola Chiapolini, January 26, 2015 27 / 36 multi+remote/shared git: Fetch git fetch Updates origin from remote local, staging area and working dir not changed Local Remote working directory staging area remote/ origin/ git fetch

Nicola Chiapolini, January 26, 2015 28 / 36 multi+remote/shared git: Merge git merge combines changes from both sources Warning: can generate conflicts! Local Remote working directory staging area remote/ origin/ git merge git fetch + git merge = git pull

Nicola Chiapolini, January 26, 2015 29 / 36 multi+remote/shared git: Conflicts Conflict!... <<<<<<< yours:sample.txt Conflict resolution is hard; let's go shopping. ======= Git makes conflict resolution easy. >>>>>>> theirs:sample.txt...

Nicola Chiapolini, January 26, 2015 30 / 36 multi+remote/shared git: Resolving Conflicts 1. See where conflicts are: git diff 2. Edit conflicting lines. 3. Add changes to the staging area: git add file1 [...] 4. Commit changes: git commit -m "Conflicts solved."

Nicola Chiapolini, January 26, 2015 31 / 36 multi+remote/shared git: Push git push Updates remote. Requires fetch+merge first. Local Remote working directory staging area remote/ origin/ git push

Nicola Chiapolini, January 26, 2015 32 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 33 / 36 Setting up a remote+shared repository. Share repository via ssh On remote server create bare+shared repository: mkdir newproject set up proper group permissions: chmod g+rws newproject cd newproject git --bare init --shared=group Everybody clones: git clone ssh://remote.com/path/newproject

Nicola Chiapolini, January 26, 2015 34 / 36 Outline Introduction Single developer + local repository Demo/Exercise: Single+Local Multiple developers + remote central repository Demo/Exercise: Multi+Remote/Shared Behind the Scenes

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Setup git init; git add [...]; git commit -m "A: init" a working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Setup git init; git add [...]; git commit -m "A: init" a HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Setup git commit -am "B" a b HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Setup git commit -am "C" a b c HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git branch devel devel a b c HEAD working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git checkout devel devel HEAD a b c working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git commit -am "D" devel HEAD a b c d working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git commit -am "E" devel HEAD d e a b c working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git checkout devel d e a b c HEAD working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git commit -am "F" devel a b c d e f HEAD working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Branches git merge devel devel a b c d e f g HEAD working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Setup git commit -am "C" a b c HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Tags git tag v1.0 a b c v1.0 HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Tags git commit -am "H" a b c v1.0 h HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git checkout b HEAD a b c v1.0 h working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git commit -am "J" HEAD j a b c v1.0 h working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git commit -am "K" HEAD j k a b c v1.0 h working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git checkout j k a b c v1.0 h HEAD working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git commit -am "K" HEAD j k a b c v1.0 h working dir staging area

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git checkout -b devel devel HEAD j k a b c v1.0 h working dir staging area devel

Nicola Chiapolini, January 26, 2015 35 / 36 Behind the Scenes: Detached HEAD git checkout devel j k a b c v1.0 h HEAD working dir staging area devel

Nicola Chiapolini, January 26, 2015 36 / 36 Questions? Understanding how git works: git foundations, by Matthew Brett: http://matthew-brett.github.com/pydagogue/foundation.html The git parable, by Tom Preston-Werner: http: //tom.preston-werner.com/2009/05/19/the-git-parable.html Excellent guides: Pro Git book: http://git-scm.com/book (FREE) git magic: http://www-cs-students.stanford.edu/~blynn/gitmagic/

Nicola Chiapolini, January 26, 2015 1 / 1 Behind the Scenes: Rebase git checkout devel devel HEAD a b c d e f working dir staging area devel

Nicola Chiapolini, January 26, 2015 1 / 1 Behind the Scenes: Rebase git rebase devel HEAD a b c f d e working dir staging area devel