Using Git for Centralized and Distributed Version Control Workflows - Day 3. 1 April, 2016 Presenter: Brian Vanderwende

Similar documents
Git Basics. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 22

MATLAB & Git Versioning: The Very Basics

MOOSE-Based Application Development on GitLab

Version Control with Svn, Git and git-svn. Kate Hedstrom ARSC, UAF

Version Control with Git. Kate Hedstrom ARSC, UAF

Introduction to Git. Markus Kötter Notes. Leinelab Workshop July 28, 2015

Version Control using Git and Github. Joseph Rivera

Introduction to the Git Version Control System

Annoyances with our current source control Can it get more comfortable? Git Appendix. Git vs Subversion. Andrey Kotlarski 13.XII.

FEEG Applied Programming 3 - Version Control and Git II

Version Control with Git. Linux Users Group UT Arlington. Rohit Rawat

Using Git for Project Management with µvision

CPSC 491. Today: Source code control. Source Code (Version) Control. Exercise: g., no git, subversion, cvs, etc.)

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

Version control with GIT

Introducing Xcode Source Control

An Introduction to Mercurial Version Control Software

Distributed Version Control with Mercurial and git

Lab Exercise Part II: Git: A distributed version control system

Introduction to Version Control with Git

Version Control with Git. Dylan Nugent

Git, GitHub & Web Hosting Workshop

Introduction to Version Control with Git

Version Control! Scenarios, Working with Git!

Version Control. Version Control

Version Control with. Ben Morgan

Git - Working with Remote Repositories

SVN Starter s Guide Compiled by Pearl Guterman June 2005

Version Control Systems (Part 2)

Version Control with Git

Source Control Systems

Version Control for Computational Economists: An Introduction

An Introduction to Mercurial Version Control Software

Introduction to Version Control

Git Basics. Christian Hanser. Institute for Applied Information Processing and Communications Graz University of Technology. 6.

Version control systems. Lecture 2

Version Control Tutorial using TortoiseSVN and. TortoiseGit

Introduction to Subversion

CS 2112 Lab: Version Control

Work. MATLAB Source Control Using Git

Git. A Distributed Version Control System. Carlos García Campos carlosgc@gsyc.es

Version Control with Subversion

Version control. HEAD is the name of the latest revision in the repository. It can be used in subversion rather than the latest revision number.

Using SVN to Manage Source RTL

Content. Development Tools 2(63)

The Bazaar Version Control System. Michael Hudson, Canonical Ltd

Data management on HPC platforms

Using SVN to Manage Source RTL

Distributed Version Control

CSE 374 Programming Concepts & Tools. Laura Campbell (Thanks to Hal Perkins) Winter 2014 Lecture 16 Version control and svn

Advanced Computing Tools for Applied Research Chapter 4. Version control

CVS versus BitKeeper A Comparison

Using Subversion in Computer Science

Version Control Using Subversion. Version Control Using Subversion 1 / 27

Using GitHub for Rally Apps (Mac Version)

Introduc)on to Version Control with Git. Pradeep Sivakumar, PhD Sr. Computa5onal Specialist Research Compu5ng, NUIT

Version Uncontrolled! : How to Manage Your Version Control

Version Control Systems

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Version Control Using Subversion. 12 May 2013 OSU CSE 1

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

Version Control Script

Revision control systems (RCS) and

Gitflow process. Adapt Learning: Gitflow process. Document control

Version control with Subversion

A Git Development Environment

Derived from Chris Cannam's original at, an.

Git Branching for Continuous Delivery

Technical Writing - Advantages of Version Control Systems

Modulo II Software Configuration Management - SCM

Version Control with Subversion and Xcode

DAVE Usage with SVN. Presentation and Tutorial v 2.0. May, 2014

CSCB07 Software Design Version Control

CISC 275: Introduction to Software Engineering. Lab 5: Introduction to Revision Control with. Charlie Greenbacker University of Delaware Fall 2011

Working Copy 1.4 users manual

Two Best Practices for Scientific Computing

PKI, Git and SVN. Adam Young. Presented by. Senior Software Engineer, Red Hat. License Licensed under

DevShop. Drupal Infrastructure in a Box. Jon Pugh CEO, Founder ThinkDrop Consulting Brooklyn NY

Subversion. Nadir SOUALEM. Linux Users subversion client svn or higher. Windows users subversion client Tortoise 1.6.

How to Create a Free Private GitHub Repository Educational Account

An Introduction to Git Version Control for SAS Programmers

Software Delivery Integration and Source Code Management. for Suppliers

Version Control Systems: SVN and GIT. How do VCS support SW development teams?

Introduction to Subversion

Software Configuration Management and Continuous Integration

Eliminate Workflow Friction with Git

Software Engineering Practices for Python

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

1. History 2. Structure 3. Git Comparison 4. File Storage 5. File Tracking 6. Staging 7. Queues (MQ) 8. Merge Tools 9. Interfaces

Version Control with Git

Developer Workshop Marc Dumontier McMaster/OSCAR-EMR

Version Control with Mercurial and SSH

ECE 4750 Computer Architecture, Fall 2015 Tutorial 2: Git Distributed Version Control System

The Hitchhiker s Guide to Github: SAS Programming Goes Social Jiangtang Hu d-wise Technologies, Inc., Morrisville, NC

BlueJ Teamwork Tutorial

Flumes Short User Guide to Subversion

Source code management systems

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

Software configuration management

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer GIT

Transcription:

Using Git for Centralized and Distributed Version Control Workflows - Day 3 1 April, 2016 Presenter: Brian Vanderwende

Git jargon from last time... Commit - a project snapshot in a repository Staging area - where additions/modifications are gathered to be packaged into a commit Clone - a copy of an existing repository HEAD - the most recent commit of the currently checked out branch Rebasing - moving the starting point of a branch from an older to a new commit in the parent branch Remote - an outside repository that is linked to the current repository (can be local or on a server) Push/pull - send/receive commits to/from a remote 2

Day 3 - Workflows, Web Servers, and Submodules 1. Git workflows a. Distributed and centralized 2. Using a web-based remote repository - Github 3. Git submodules 3

While Git can be used for local collaboration, it was designed for large distributed workflows In a distributed workflow, devs can clone an official public repository to create private development repos. The developer then pushes their changes to their own public repository, from which the official project maintainer can pull to the official repo. This is also called the integrator workflow, because the official maintainer integrates features from developers Implicitly provides security and redundancy 4

Visualizing the distributed workflow Developer Maintainer Private Repository Push Pull/Fetch Private Repository Public Repository Public Fork Repository Developer Private Repository The maintainer is the development integrator Public Fork Repository 5

Centralized workflows, involving a central repository, are also possible with Git In this model, all developers have a private repository, from which they can push features to a central (typically networked) repository Similar to the Subversion workflow All developers are responsible for resolving commit conflicts with other pushed changes There is no integrator in this model 6

Visualizing the centralized workflow Central Server Public Repository Push Pull/Fetch Developer Private Repository Developer Private Repository 7

Public repositories are typically created without a working directory for obvious (?) reasons Use the bare option to create a repository without a working directory: git init --bare <repo_name>.git Note the.git at the end of the repository name. This accepted convention is used when no working directory exists. 8

Of course, hybrid workflows with distributed groups accessing a central server are possible too! 9

Github and competitors simply provide webhosting and tools for Git repositories Provide an easy method for cross-network collaboration as well as source distribution Add visual flair to the Git experience (web GUI) Can be incorporated into any workflow: In centralized, the public repository is stored on web server, and all developers are given push access In distributed, developers can store public repositories online (including the integrator and the official repository) 10

You may recall, I hosted the sample repository for this workshop on Github. Let s explore that process... 11

Earlier, I wanted to set up a public repository for my workshop roster website project on Github 12

Next, I needed to push my private repository to the public Github repository Git allows for HTTPS or SSH authentication. I find SSH to be more reliable, but you do need to set up an SSH key. git remote add origin git@github.com:vanderwb/roster_site.git git push -u origin master 13

A quick note about Github permissions By default, public repositories are open access Anyone can view the repository (all users have read/pull access) Anyone can issue a pull-request to the repository This enables and follows the integrator workflow The owner of the repository can add collaborators These users have write access, meaning they can push commits to the repository Collaborators enable the centralized workflow 14

What if I want to nest one Git repository within another? 15

The simplest approach is to nest the subproject within a directory, and add to.gitignore Superproject Files.gitignore Folders Files Subproject Files Easy to set up Repositories act independently Must be pushed/pulled independently Problem: if another user clones the superproject, subprojects are not cloned with it 16

We need a way to link the subproject to the superproject without mixing their commits... 17

First, let s think about the Subversion solution to this problem: externals Creating an external in SVN is (relatively) easy Create a directory for the embedded project Set the directory to be an external by associating the repository URL Commit the external to the superproject Now, whenever you update the superproject, the external will be updated as well If the external is in the same repository, any changes to it will be included in the commit list If not, you have to commit changes separately 18

In Git, submodules provide some of the advantages of externals, with a few important differences A submodule is a copy of a single commit from the subproject repository, kept in a subdirectory of the superproject repository The directory structure of the superproject and URL of the subproject repository are maintained when cloning However, unlike SVN:externals, submodules are locked to a single commit at any one time, and don t automatically track the external project s HEAD 19

How do you add a submodule to a repository? A submodule is basically a special remote embedded in the superproject repository. So we add it: git submodule add [-b <branch>] <URL> By default, the submodule directory will have the same name as the source repository A new, version controlled, file called.gitmodules stores the mapping of the repository to the directory You can manually track a submodule branch using -b If not set, the submodule will default to the master branch 20

Use recursive cloning when copying a repository with submodules To properly clone a repository with submodules, use: git clone --recursive <source-url> <dest-url> Otherwise, you will get an empty submodule folder. You can recover from that by running: git submodule init git submodule update 21

First way to update the submodule - pull the commit tracked by the superproject The superproject tracks a single commit for each subproject/submodule After pulling a superproject commit that points to a newer submodule commit, update the submodule contents using (i.e. load the commit): git submodule update [--merge/--rebase] If your submodule diverges from the updates, a merge or rebase will be required 22

First way to update the submodule - pull the commit tracked by the superproject Initial state Pull new superproject Update submodule Superproject dj194bs Submodule aab42a3 Superproject chw3l91 Submodule c273ab8 Superproject chw3l91 Submodule c273ab8 Subrepo aab42a3 Subrepo aab42a3 Subrepo c273ab8 23

Second way to update the submodule - pull the latest commit from the subproject branch The submodule is itself a remote repository You can pull the latest changes from the targeted branch of the subproject by doing a remote update git submodule update --remote The tracked branch can be changed as follows: git config -f.gitmodules submodule.<path>.branch <branch> 24

Second way to update the submodule - pull the latest commit from the subproject branch Initial state Update submodule Commit to superproject Superproject dj194bs Submodule aab42a3 Superproject dj194bs Submodule aab42a3 Superproject chw3l91 Submodule c273ab8 Subrepo aab42a3 Subrepo c273ab8 Subrepo c273ab8 25

Changes made in the submodule must be committed within the subproject AND superproject If you make modifications to the subproject, you must commit them, and then stage and commit the submodule itself within the superproject subproject$ echo "TBD" > hello_gpu.f90 subproject$ git add hello_gpu.f90 subproject$ git commit -m "Added stub file for hello world GPU program" subproject$ cd.. superproject$ git diff diff --git a/subproject b/subproject index 208f4f8..3479225 160000 --- a/subproject +++ b/subproject @@ -1 +1 @@ -Subproject commit 208f4f884c99ff26f012dbe36b50e3a7411af9f8 +Subproject commit 3479225ec1636dae3f29902200a8980a589c270d superproject$ git commit -am "Updated submodule" superproject$ git diff 26

Submodule pushing can be done recursively from within the superproject Submodule changes must be pushed before superproject changes! If you want Git to simply check for submodule changes, and terminate the push if they are found: git push --recurse-submodules=check If you want Git to first push submodule changes: git push --recurse-submodules=on-demand 27

CAUTION: Git s heavy focus on branches can cause problems when submodules are introduced... $ git checkout -b add_sub $ git submodule add../subproject $ git commit -am "Added submodule" $ git checkout master warning: unable to rmdir subproject: Directory not empty Switched to branch 'master' $ git status On branch master Untracked files: subproject/ $ rm -rf subproject $ git status On branch master nothing to commit, working directory clean $ git checkout add_sub $ ls subproject/ $ git submodule update Submodule path 'subproject': checked out '208f4f884c99ff26f012dbe36b50e3a7411af9f8' $ ls subproject/ hello_mpi.f90 hello_serial.f90 28

Making life easier when using submodules Git aliases come in handy as many submodule commands are long and cumbersome: git config alias.spush push --recurse-submodules=on-demand git config alias.supdate submodule update --remote --merge The foreach command can be used to send any command to all submodules. For example: git submodule foreach git checkout -b <branch> 29

Integrating a subversion repository into a Git project using submodules requires a Git clone If Git, SVN, and Alien::SVN are installed, can use git-svn to clone an SVN repository in Git. On Yellowstone: module load git module load git-svn git svn clone -s <SVN-URL> <clone-path> Then, in the Git superproject, make the clone a submodule using git submodule add <clone-path> 30

Updating the SVN submodule is a clunky process Need to resync with upstream SVN repo, pull changes to the submodule, and update the superproject: cd <clone_path> git svn rebase cd <superproject_path/subproject> git checkout master git pull cd.. git add <subproject> git commit -m Updated submodule to vx.x 31

Github can make the Git/SVN transition easier, as both programs can interact with Github repositories 32

For more information, check out man pages and: https://git-scm.com/doc http://rypress.com/tutorials/git/index http://nvie.com/posts/a-successful-git-branching-model/ https://www.atlassian.com/git/tutorials/ My contact information: Brian Vanderwende CISL Consulting Services Group ML-55L (x2442) vanderwb@ucar.edu 33