Git: Distributed Version Control

Similar documents
Git: Distributed Version Control

Git: (Distributed) Version Control

Git: (Distributed) Version Control

Version control CSE 403

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 System - Git. zswu

Version control CSE 403

Introduction to Git and Github

Revision control. INF5750/ Lecture 2 (Part I)

Git. Presenter: Haotao (Eric) Lai Contact:

Version control CSE 403

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

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

Introduction to distributed version control with git

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

Introduction to Version Control

CSE 391 Lecture 9. Version control with Git

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

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

Version Control: Gitting Started

Improving Your Life With Git

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

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

Software Project (Lecture 4): Git & Github

Computer Science Design I Version Control with Git

FEEG Applied Programming 3 - Version Control and Git II

Lab Exercise Git: A distributed version control system

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

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


Introduction to Git and Github Repositories

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

CS 390 Software Engineering Lecture 5 More Git

Lecture 6 Remotes. Sign in on the attendance sheet!

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

Git & Github Fundamental by Rajesh Kumar.

Git Introduction CS 400. February 11, 2018

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

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

A BASIC UNDERSTANDING OF VERSION CONTROL

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

GIT FOR SYSTEM ADMINS JUSTIN ELLIOTT PENN STATE UNIVERSITY

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

Git for Newbies. ComMouse Dongyue Studio

Git. Ľubomír Prda. IT4Innovations.

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

Version control system (VCS)

Version Control with GIT

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

Distributed Version Control

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

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

Git Basi, workflow e concetti avanzati (pt2)

Revision Control and GIT

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

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

Submitting your Work using GIT

Algorithm Engineering

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

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

MOOSE-Based Application Development on GitLab

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

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

Table of Contents. Concepts

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

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

Source Code Management wih git

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

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

Git version control with Eclipse (EGit) Tutorial

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

Revision Control. An Introduction Using Git 1/15

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

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

Git tutorial. Katie Osterried C2SM. October 22, 2015

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

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

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

Git for Version Control

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

Version Control Systems

Online Remote Repositories

Project Management. Overview

Using GitHub and SourceTree to work with DITA TC repositories

TDDC88 Lab 4 Software Configuration Management

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

GIT. A free and open source distributed version control system. User Guide. January, Department of Computer Science and Engineering

Barry Grant

How to be a git. Dominic Mitchell

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

Version Control Systems (VCS)

Using git to download and update BOUT++

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

Version Control. Version Control

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

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

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

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

Transcription:

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

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: changesets! Communication between teammates is to bring stores in sync Basic operators: fetch and push

Sarah's Repository Sarah a b c d e wt

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

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

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

Remote Repository Unchanged Matt a b f g

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

Remote Repository Unchanged Matt a b f g

View of DAG with All Branches $ git log --oneline --graph --decorate --all * 1618849 (, origin/, ) clean up css * d579fa2 (alert) merge in improvements from \ * 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

Matt s Repository after Fetch matt$ git fetch sr

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

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

Matt s Repository after Merge matt$ git merge sr/

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 (ie no working tree, so 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 fix a b c d wt

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

Commit/Checkout vs Push/Fetch

Common Topology: Star 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)

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 (e.g., 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 # 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

Warning: Academic Misconduct GitHub is a very popular service But only public repo's are free Edu discount gives you 5 private repo's 3901 has an account for creating more 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 5, but 4 is better) 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)

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

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 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 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 (and attached branch) moved maint a b c d now unreachable wt replaced to be same as ~1 ind