Git: Distributed Version Control

Similar documents
Git: Distributed Version Control

Git: (Distributed) Version Control

Git: (Distributed) Version Control

Version control CSE 403

Version Control System - Git. zswu

Introduction to Git and Github

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

Version control CSE 403

FEEG Applied Programming 3 - Version Control and Git II

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

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:

Software Development I

Software Project (Lecture 4): Git & Github

Revision control. INF5750/ Lecture 2 (Part I)

Introduction to distributed version control with git

CS 390 Software Engineering Lecture 5 More Git

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

Version control CSE 403

Git & Github Fundamental by Rajesh Kumar.

Git Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : October, More documents are freely available at PythonDSP

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

Git. Presenter: Haotao (Eric) Lai Contact:

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

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

Version Control: Gitting Started

Git for Newbies. ComMouse Dongyue Studio

Introduction to Version Control


Improving Your Life With Git

CSE 391 Lecture 9. Version control with Git

Git Introduction CS 400. February 11, 2018

Lab Exercise Git: A distributed version control system

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

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

Computer Science Design I Version Control with Git

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

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

Version Control. Software Carpentry Github s Hello World Git For Ages 4 And Up You need source code control now

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

Introduction to Git and Github Repositories

2 Initialize a git repository on your machine, add a README file, commit and push

Source Code Management wih git

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

Version Control with GIT

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

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

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

Git Basi, workflow e concetti avanzati (pt2)

A BASIC UNDERSTANDING OF VERSION CONTROL

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

Revision Control and GIT

Version control with Git.

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

Version control system (VCS)

Git. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

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

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

Distributed Version Control

How to be a git. Dominic Mitchell

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

Table of Contents. Concepts

Version Control Systems

Submitting your Work using GIT

! #Running this command from the top directory of your project will add all your changes."! $ git add."

Creating a Patch. Created by Carl Heymann on 2010 Sep 14 1

Algorithm Engineering

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

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

FAQ Q: Where/in which branch do I create new code/modify existing code? A: Q: How do I commit new changes? A:

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

Project Management. Overview

Common Git Commands. Git Crash Course. Teon Banek April 7, Teon Banek (TakeLab) Common Git Commands TakeLab 1 / 18

Git version control with Eclipse (EGit) Tutorial

Version Control. Version Control

Lecture 6 Remotes. Sign in on the attendance sheet!

Git tutorial. Katie Osterried C2SM. October 22, 2015

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

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

Git. Ľubomír Prda. IT4Innovations.

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

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

Barry Grant

Software Development. Using GIT. Pr. Olivier Gruber. Laboratoire d'informatique de Grenoble Université de Grenoble-Alpes

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

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

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

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

Online Remote Repositories

GIT Princípy tvorby softvéru, FMFI UK Jana Kostičová,

Git and GitHub. Dan Wysocki. February 12, Dan Wysocki Git and GitHub February 12, / 48

Visualizing Git Workflows. A visual guide to 539 workflows

Git for Subversion users

Version Control. Version Control

L Modeling and Simulating Social Systems with MATLAB

Week 5. CS 400 Programming III

G E T T I N G S TA R T E D W I T H G I T

Chapter 5. Version Control: Git

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

MOOSE-Based Application Development on GitLab

TDDC88 Lab 4 Software Configuration Management

Transcription:

Git: Distributed Version Control Computer Science and Engineering College of Engineering The Ohio State University Lecture 3

Demo Prep: Empty (but initialized) repo Linear development: Create, edit, rename, ls -la files Git: add, status, commit, log Checkout (time travel, detach ) Branch (reattach ) More commits, see split in history Merge No conflict Fast-forward

What Does "D" Stand For? Distributed version control Multiple people, distributed across network Each person has their own repository! Everyone has their own store (history)! Big difference with older VCS (eg SVN) Units of data movement: changeset Communication between teammates is to bring stores in sync Basic operators: fetch and push

Sarah's Repository Sarah a b c d master e wt

And Matt's Repository Sarah a b c d master e wt Matt a b f master g wt

Some Shared History Sarah a b c d master e wt Matt a b f master g wt

Fetch: Remote Store Local sarah$ git fetch mt Sarah a b c d master e wt f g working tree unaffected! mt/master new changesets added to store remote branch

Remote Repository Unchanged Matt master a b f g

Workflow: Merge After Fetch sarah$ git merge mt/master Sarah master a b c d e h f g mt/master

Remote Repository Unchanged Matt master a b f g

View of DAG with All Branches $ git log --oneline --graph --decorate --all * 1618849 (, origin/master, master) clean up css * d579fa2 (alert) merge in improvements from master \ * 0f10869 replace image-url helper in css * b595b10 (origin/alert) add buckeye alert notes * a6e8eb3 add raw buckeye alert download / * b4e201c wrap osu layout around content * e9d3686 add Rakefile and refactor schedule loop * 515aaa3 create README.md * eb26605 initial commit

Your Turn Show the state of Matt's repository after each of the following steps Fetch (from Sarah) Merge

Sarah and Matt's Repositories Sarah master a b c d e h f g Matt master mt/master a b f g

Some Shared History Sarah master a b c d e h f g Matt master mt/master a b f g

Your Turn: Fetch matt$ git fetch sr

Your Turn: Merge matt$ git merge sr/master

Pull: Fetch then Merge A "pull" combines both fetch & merge matt$ git pull sr Advice: Prefer explicit fetch, merge After fetch, examine new work $ git log --all #see commit messages $ git checkout #see work $ git diff #compare Then merge Easier to adopt more complex workflows (e.g., rebasing instead of merging)

Push: Local Store Remote Push sends local commits to remote store Usually push one branch (at a time) sarah$ git push mt fix Advances Matt's fix branch Advances Sarah's mt/fix remote branch Requires: 1. Matt's fix branch must not be his 2. Matt's fix branch must be ancestor of Sarah's Common practices: 1. Only push to bare repositories (bare means no working tree, ie no ) 2. Get remote store's branch into local DAG (ie fetch, merge, commit) before pushing

Remote's Branch is Ancestor Sarah mt/fix fix a b c d e Matt master fix a b c d wt

Push: Local Store Remote sarah$ git push mt fix Sarah mt/fix fix a b c d e Matt master fix a b c d wt

Push: After sarah$ git push mt fix Sarah fix mt/fix a b c d e working tree unaffected! Matt master fix a b c d e wt

Commit/Checkout vs Push/Fetch

Common Topology: Star n-person team has n+1 repositories 1 shared central repository (bare!) 1 local repository / developer Each developer clones central repository Cloning creates a remote called "origin" Default source/destination for fetch/push Variations for central repository: Everyone can read and write (ie push) Everyone can read, but only 1 person can write (responsible for pulling and merging)

Common Topology: Star Bare repository (no working tree) Source: http://nvie.com/posts/a-successful-git-branching-model/

Workflow: Configure Git Each team member, in their own VM Set identity for authoring commits $ git config --global user.name "Brutus Buckeye" $ git config --global user.email bb@osu.edu Optional: diff and merge tool (eg meld) $ sudo apt-get install meld # to get tool $ git config --global merge.tool meld $ git config --global diff.tool meld # example use: $ git difftool e9d36

Workflow: Initialize Central Rep One person, once (ssh'ed to stdlinux): Create central repository in group's project directory (/project/c3901aa03) $ cd /project/c3901aa03 $ mkdir rep.git # ordinary directory Initialize central repository as bare and shared within the group $ git init --bare --shared rep.git Note: Hosting services (eg GitHub, BitBucket) often have a web interface for this step

Workflow: Initialize Repository Each team member, once, in their VM Create local repository by cloning the central repository $ git clone ssh://brutus@stdlinux.cse.ohiostate.edu//project/c3901aa03/rep.git mywork You will be prompted for your (stdlinux) password (every time you fetch and push too) To avoid having to enter your password each time, create an ssh key-pair (see VM setup instructions)

Ignoring Files from Working Tree Use a.gitignore file in root of project # Ignore auto-saved emacs files *~ # Ignore bundler config /.bundle # Ignore the default SQLite database /db/*.sqlite3 # Ignore all logfiles and tempfiles /log/*.log /tmp

Workflow: Local Development Each team member repeats: Edit and commit (to local repository) often $ git status/add/rm/commit Pull others' work when can benefit $ git fetch origin # bring in changes $ git log/checkout # examine new work $ git merge, commit # merge work Push to central repository when confident $ git push origin master # share

Git Clients and Hosting Services Recommended client: Command line! Various GUIs: Linux: gitg, git-gui, git-cola, giggle Win/mac GUI: SourceTree Lots of sites for hosting your repos: GitHub, Bitbucket, SourceForge, Google Code, These cloud services provide Storage space Pretty web interface Issues, bug tracking Workflow with "forks" and "pull requests" to promote contributions from others

Clarity git!= GitHub

Warning: Academic Misconduct GitHub is a very popular service But only public repo's are free Edu discount gives you private repo's 3901 has an account ("organization") for private repo's (see class web site) Bitbucket has free private repo's, for small teams (< 5 collaborators) Public repo's containing coursework can create academic misconduct issues Problems for poster Problems for plagiarist

Summary Push/fetch to share your store with remote repositories Neither working tree is affected Branches in history are easy to form Committing when is not a leaf Fetching work based on earlier commit Advice Learn by using the command line Beware academic misconduct

Group Formation Groups of 4 (or 3) Exchange contact information Each person choose a primary technical area: HTML/CSS JavaScript Ruby Group constraints on choices: Each technology must be represented No more than 2 people per technology Choose a secondary interest as well Don t Care is fine (as primary or secondary)

Advanced: Undoing Mistakes Say you want to throw away all your uncommited work ie "Roll back" to last commited state Checkout won't work! maint master a b c d wt uncommited changes δ ind

Reset: Discarding Changes $ git reset --hard $ git clean -dry-run # list untracked files $ git clean -force # remove untracked files maint master a b c d replaced to be same as δ wt ind

Reset: Discarding Commits $ git reset --hard ~1 # no need to git clean, since wt was already clean moved (and attached branch) maint master a b c d now unreachable wt replaced to be same as ~1 ind

Mercurial (hg): Another DVCS Slightly simpler mental model Some differences in terminology git fetch/pull ~= hg pull/fetch git checkout ~= hg update Some (minor) differences in features No rebasing (only merging) No octopus merge (#parents <= 2) But key ideas are identical Repository = working directory + store Send/Receive changes between stores