Version Control with Git. Kate Hedstrom ARSC, UAF



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

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

Introduction to Version Control

Version Control with Git. Dylan Nugent

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

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

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

Version control with GIT

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

Version Control with. Ben Morgan

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

Version Control using Git and Github. Joseph Rivera

Introduction to the Git Version Control System

MATLAB & Git Versioning: The Very Basics

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

MOOSE-Based Application Development on GitLab

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.

Data management on HPC platforms

An Introduction to Mercurial Version Control Software

Version Control with Git

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

Two Best Practices for Scientific Computing

An Introduction to Git Version Control for SAS Programmers

Version Control. Version Control

Introduction to Version Control with Git

FEEG Applied Programming 3 - Version Control and Git II

Using Git for Project Management with µvision

Source Control Systems

Version Control with Git

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

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

Version Control Tutorial using TortoiseSVN and. TortoiseGit

Distributed Version Control with Mercurial and git

Work. MATLAB Source Control Using Git

An Introduction to Mercurial Version Control Software

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

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

Version Control Systems

Version Control with Subversion

Revision control systems (RCS) and

Version Control! Scenarios, Working with Git!

Version Control Script

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

Introduction to Version Control with Git

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

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

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

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

SVN Starter s Guide Compiled by Pearl Guterman June 2005

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

Gitflow process. Adapt Learning: Gitflow process. Document control

Advanced Computing Tools for Applied Research Chapter 4. Version control

Version control with Subversion

Software Configuration Management and Continuous Integration

Version Control with Subversion and Xcode

Derived from Chris Cannam's original at, an.

Intro etckeeper bup ikiwiki git-annex vcsh mr Zsh Outro. Gitify your life. web, blog, configs, data, and backups

Pro Git. Scott Chacon *

CS 2112 Lab: Version Control

Using SVN to Manage Source RTL

Using SVN to Manage Source RTL

Version Control with Mercurial and SSH

Miguel A. Figueroa Villanueva Xabriel J. Collazo Mojica. ICOM 5047 Capstone Miguel A. Figueroa Villanueva University of Puerto Rico Mayagüez Campus

Xcode Source Management Guide. (Legacy)

CSCB07 Software Design Version Control

Introducing Xcode Source Control

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

Version Control Tools

Source code management systems

Git - Working with Remote Repositories

Version Control with Subversion

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

Mercurial. Why version control (Single users)

A Git Development Environment

Developer Workshop Marc Dumontier McMaster/OSCAR-EMR

Software configuration management

Using Subversion in Computer Science

Integrated version control with Fossil SCM

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

Continuous Integration. CSC 440: Software Engineering Slide #1

Content. Development Tools 2(63)

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

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

Unity Version Control

Version Control for Computational Economists: An Introduction

Working Copy 1.4 users manual

Git Internals. Source code control and beyond by Scott Chacon

Putting It All Together. Vagrant Drush Version Control

Source Code Management/Version Control

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

Git Tutorial - How to Create a Full Project

Source Code Management for Continuous Integration and Deployment. Version 1.0 DO NOT DISTRIBUTE

Transcription:

1 Version Control with Git Kate Hedstrom ARSC, UAF

Linus Torvalds

3 Version Control Software System for managing source files For groups of people working on the same code When you need to get back last week s version In the past, I have used RCS, CVS, and SVN, each better than the last Git was designed for managing the Linux kernel and therefore has these goals: Fast Support many, many developers Distributed

Distributed? Every checkout gives you a copy of the whole repository Can compare branches, history while offline Can check in your changes to your local repository Sharing updates with others is optional

5 Getting Started With Git Set up who you are: % git config -global user.name you % git config -global user.email \ you@home Get colorful (if you want): % git config -global color.ui auto Without --global applies to current directory only

Start a New Repository In the directory with your code: git init git add. git commit -m initial message You now have a.git directory with a database of your files Revision numbers are SHA1 numbers, same for the same content

From a Repository From a git url: git clone <url> Could be another local directory: git clone dir1 dir2 From an svn url: git svn clone <url> Default is to suck down the entire history into the database

Main git commands add add sources to next commit commit check in changes locally checkout change branches push send your changes to a remote site pull/fetch get changes from remote site status - find out which files would change on commit diff find out what's different between index and current sandbox help 8

9 Example Change/add some local files git add newfile git commit git add adds files to the commit list for the next commit Can selectively add only some of your changes to make logical commits git commit -a #commits all changes

Git example % ls /my/src/cpp cpp.h cpp.c Makefile... % cd /my/src/cpp % git init # Tell git which files to track % git add. % git commit [make some changes] % git commit -a

Comments on Previous Svn takes more fuss to get going (not shown) Tracked files have to be explicitly added Any directory can be come a git repository Better for text files than for binary

What about Branches? See the branches: git branch Make a new branch: git branch <new> # copy of current Switch to that new branch: git checkout <new>

git log gitk (gui) git diff HEAD^ Seeing History git log HEAD^^^ or HEAD~3 git diff b324a87 (SHA1) git diff --cached (between index and HEAD)

Index? The index is a store of what would be checked in on commit Contains files that merged cleanly and those put in with git add git diff shows difference between index and current sandbox git diff HEAD shows difference between last checked in and sandbox

Index as Staging Area HEAD

16 Coordination # on pacman % git clone <URL> roms % cd roms [make some changes] % git commit -a % git push origin master # on this Mac % git clone % cd roms % git pull % make Coordinate code on multiple systems Coordinate between multiple programmers Can be single version or multiple branches

17 Updates An update when two people have changed things can involve: No conflict because changes are in different places Conflict because two different changes to the same region in the code If there is a conflict this must be resolved by human intervention One option is to reset (undo the merge)

18 Other git commands delete no longer need a file move rename a file or move to new location merge merge changes from another branch cherry-pick pick one update from some other branch remote register a remote repo rebase reorder the history in your local repo

Revision Numbers git uses a database to store the files The branch has one revision number to describe that snapshot it s a SHA1 with 40 characters SHA1 for each file SHA1 for a tree of files Can see the numbers with git log Every commit creates a new revision number

20 Branches A branch starts as a duplicate Delete branches after merge and testing Rebase can be used to put change 7 after 6

21 Conflicts If there is a conflict, git will let you know The merge failures will look something like: Clean code before <<<<<<< HEAD:<file> My code ======= New code >>>>>>> branch:<file> Clean code after

22 More Conflicts Once you ve cleaned up the mess, tell git you re ready: git add filename This will cause git to place the new version into the index You can instead toss your changes with: git checkout HEAD filename Once all the files are clear (check with git status ) commit the index to the repo: git commit

Other Remote repos are seen as a kind of branch git remote update! Always, always check in changes before a pull/fetch/merge this is different from svn. Check in changes before changing branches unless you want the change to be on the other branch

Git Svn Handshaking Not quite as robust as git alone Based on Perl scripts in svn distribution (not always installed) git svn clone <url> git svn clone -r 1043 <url> git svn rebase # fetch from upstream git svn dcommit # commit to upstream git svn log

Bare Repositories Full database, but no working files Create with git clone --bare url For repositories that get pushed to (web servers, for example)

My Insane Repo Collection Bare repository on Linux workstation Cloned to each supercomputer via ssh Cloned to alnilam (colleague s) via ssh git-svn only working on Mac Mac has my git-svn repo, plus clone of workstation repo, also NCAR CESM- ROMS and Hernan s trunk via git-svn

My Insane Repo Collection

Git Drawbacks? Best with one project per repository (roms, plotting, matlab tools all separate entities) Yet another tool to learn Git-svn doesn t handle svn Externals More rope to hang yourself

My Branches Copy of the svn code (public) Fish model branch Larval model branch (with tripole grid) Any other thing I'm working on temporarily

30 Learn more Version Control with Git, by Jon Loeliger, 2009, O Reilly Online at http://git-scm.com/documentation - there are even videos git help If you like these ideas, but prefer a Python tool, check out Mercurial at: http://mercurial.selenic.com/

Work Along? git config --global user.name me git config --global user.email me@work git config --global color.ui auto Find some code to track... If desperate: http://www.people.arsc.edu/~kate/simple_codes/

In Code Directory git init git add. git commit # or git add *.f # -m message make a change... git status git commit -a

Ignoring Files Edit.gitignore git add.gitignore git diff HEAD git commit gitk Can look at.git/config

Branches git branch hotter git checkout hotter Edit some file git commit -a git checkout master Edit same file git merge hotter

Conflict? then Clone Fix conflict git add file git commit git branch -d hotter cd.. git clone dir1 dir2 Check dir2/.git/config