Similar documents
USPAS Simulation of Beam and Plasma Systems

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

Git tutorial. Katie Osterried C2SM. October 22, 2015

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

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

Git. Presenter: Haotao (Eric) Lai Contact:

Fundamentals of Git 1

Computer Science Design I Version Control with Git

Version Control with GIT

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

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

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

Git for Version Control

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

CSE 391 Lecture 9. Version control with Git

CS314 Software Engineering Configuration Management

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

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

Version Control System - Git. zswu

Source Code Management wih git

Revision control. INF5750/ Lecture 2 (Part I)

DEVNET Introduction to Git. Ashley Roach Principal Engineer Evangelist

Introduction to Version Control

Version Control Systems (VCS)

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

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

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

A BASIC UNDERSTANDING OF VERSION CONTROL

Version Control with Git ME 461 Fall 2018

Distributed Version Control

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

Version Control Systems

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

Version Control Systems (Part 1)

2/9/2013 LAB OUTLINE INTRODUCTION TO VCS WHY VERSION CONTROL SYSTEM(VCS)? II SENG 371 SOFTWARE EVOLUTION VERSION CONTROL SYSTEMS

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

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

Version control with Git.

Version Control Systems. Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

Git: Distributed Version Control

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Subversion (and Git) Winter 2019

Version Control System GIT

Version Control. CSC207 Fall 2014

Introduction to distributed version control with git

Version Control Systems: Overview

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

Revision Control and GIT

Lab Objective. Lab Assignment. Downloads and Installation

Software Development I

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

Software Project (Lecture 4): Git & Github

Github/Git Primer. Tyler Hague

Git for Newbies. ComMouse Dongyue Studio

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

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

Beyond git add/commit/push

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

Using git to download and update BOUT++

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani -

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

Git: Distributed Version Control

Git, the magical version control

Version Control: Gitting Started

CS 390 Software Engineering Lecture 5 More Git

Lab 08. Command Line and Git

Version control system (VCS)

CS 520: VCS and Git. Intermediate Topics Ben Kushigian

Lab Exercise Git: A distributed version control system

A Brief Git Primer for CS 350

FEEG Applied Programming 3 - Version Control and Git II

Git Basi, workflow e concetti avanzati (pt2)

Git(Lab) Tutorial and Hands-On

Windows. Everywhere else

Object Oriented Programming. Week 1 Part 2 Git and egit

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

GIT TUTORIAL. Creative Software Architectures for Collaborative Projects CS 130 Donald J. Patterson

Managing Network Configurations with Git and GitLab

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

Version Control for Fun and Profit

Getting started with GitHub

Tools for software development:

Project Management. Overview

Version Control. Version Control

Visualizing Git Workflows. A visual guide to 539 workflows

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

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

Using Git For Development. Shantanu Pavgi, UAB IT Research Computing

L Modeling and Simulating Social Systems with MATLAB

CS 320 Introduction to Software Engineering Spring February 06, 2017

Working with GIT. Florido Paganelli Lund University MNXB Florido Paganelli MNXB Working with git 1/47

Improving Your Life With Git

Intro to Github. Jessica Young

Git better. Collaborative project management using Git and GitHub. Matteo Sostero March 13, Sant Anna School of Advanced Studies

Overview. 1. Install git and create a Github account 2. What is git? 3. How does git work? 4. What is GitHub? 5. Quick example using git and GitHub

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

Reproducibility with git and rmarkdown

Version Control with GIT: an introduction

Version Control with Git

Transcription:

USPAS Simulation of Beam and Plasma Systems Steven M. Lund, Jean-Luc Vay, Remi Lehe, Daniel Winklehner and David L. Bruhwiler Lecture: Software Version Control Instructor: David L. Bruhwiler Contributors: R. Nagler, P. Barbe and P. Moeller U.S. Particle Accelerator School sponsored by Old Dominion University http://uspas.fnal.gov/programs/2018/odu/courses/beam-plasma-systems.shtml January 15-26, 2018 Hampton, Virginia This material is based upon work supported by the U.S. Department of Energy, Office of Science, Offices of High Energy Physics and Basic Energy Sciences, under Award Number(s) DE-SC0011237 and DE-SC0011340.

Centralized version control systems (VCS) A version control system (VCS) records changes to a set of files Manual version control (ad hoc, error prone) copy file versions with some convention for naming, location, etc. ad hoc, error prone, difficult to collaborate Centralized software version control enables collaboration reliable recovery of previous states CVS, Subversion (SVN), many others Criticisms of centralized systems server is a single point of failure if server goes down for an hour nobody has access if database becomes corrupted all recent work is lost (since backup) except for individual snapshots all these criticisms are addressed by a well-managed system # 2

Distributed vs Central models Centralized version control systems focuses on synchronizing, tracking, and backing up files recording/downloading is simultaneous with applying a change primary repo is a database on a central server the entire change history, including branches, is part of the central database user repositories are snapshots that get synched with the central database Distributed version control systems focuses on sharing changes; every change has a unique guid recording/downloading is separate from applying a change the hierarchical structure is not required one can create a centrally administered location, if it is convenient alternatively, one can treat all repositories as equal peers this results in new concepts and associated terminology push: send a change to another repository pull: grab a change from a repository the change history, including branches, are distributed every user repo is self-contained # 3

git Getting Started It is assumed you are working on the Linux command line Establish your git identity (name & email) for the local client every git commit uses this information it s immutably baked into the commits you start creating $ git config --global user.name "My Name" $ git config --global user.email my_name@example.com you need do this only once if you pass the --global option many GUI tools will help you do this when you first run them Configure the default text editor $ git config --global core.editor emacs used when git needs you to type a message if not configured, git uses your system s default editor # 4

Any questions at this point? Class discussion: Any concerns about using git from the command line (CL)? git is a distributed VCS implementation the classroom computers provide git on Linux 2 students per computer, but only one Linux login this means you ll have to share a single git identity Work from your laptop if it has a good CL environment, with git installed PyCharm supports interaction with git, GitHub and other VCS options You can download/install the GitHub desktop application https://desktop.github.com it installs git on your Windows or MacOS laptop it provides an optional command-line terminal for using git Today s computer lab exercises will provide some practical experience # 5

git Underlying Concepts (Part 1) The git CLI is not intuitive, compared to central model applications (e.g. svn) it helps if you understand the underlying concepts The git commit tree information is representable as a graph each node results from an operation database is immutable and append-only an example git Tree (see figure) each node is associated with the developer s commit message a unique hash (guid) Git references a reference (ref) is a human readable label, pointing to a commit hash branches, tags, remotes are all forms of refs refs facilitate interaction with the commit tree refs do not hold the information in the git database all such info is held within the commit tree, which is immutable suppose the git repository is in a bad state, and we want to back track all previous states are still present inside the tree we need only change the references to the desired commit address git provides a special reference named HEAD current address for the state that is checked out in the working directory # 6

git Underlying Concepts (Part 2) The state of a git repository has three components Working Directory result of cloning a git repository a directory with everything contained within the git repository Staging Index an intermediate space to add changes from the working directory (without adding them to the commit tree) Commit Tree changes in the staging index are (when ready) added to the commit tree each change is given a hash address Cloning a repository Create a local copy this is complete and independent from the source git supports various protocols: $ git clone [<options>] <repo> [<dir>] Docs for git clone, https://git-scm.com/docs/git-clone If no [<dir>], git creates a new directory with the same name as the repo local filesystem clone $ git clone /Path/To/Git/Repo/Dir remote HTTPS clone from GitHub $ git clone https://github.com/radiasoft/devops.git # 7

git the Checkout command It changes the HEAD reference, making it point to a new address affects only the working directory secondary use: undo changes in the working directory $ git checkout [<options>] <branch> Useful examples: get latest commit from the master branch for use in currently active branch $ git checkout master get an address (e.g. 2d52a68) and label it as branch new_branch_name $ git checkout -b new_branch_name 2d52a68 force a checkout from master branch, throwing away local modifications $ git checkout -f master revert changes in file my_file.py $ git checkout path/to/my_file.py Docs for git checkout, https://git-scm.com/docs/git-checkout revert file my_file.py to its state in the branch my_branch $ git checkout my_branch -- path/to/my_file.py # 8

git how to Stage and Commit Staging add changes from the working directory to staging index add new (untracked) file to staging index (or new changes to a tracked file) $ git add path/to/file add all changes of tracked files to the staging index $ git add u Docs for git add, https://git-scm.com/docs/git-add Commit store changes within the commit tree changes may come from the staging index or directly from the working directory each commit requires a message to document the changes being recorded Some examples: commit the staging index, and document with a message if don t specify an inline message, an editor will be invoked $ git commit m this is my commit message commit all changes in tracked files $ git add a commit changes within a specific file $ git commit /path/to/file m file is better now Docs for git commit, https://git-scm.com/docs/git-commit # 9

git Push & Pull Pull performs a fetch and merge in one step pull the remote tracking branch into the current working directory if you clone a repo, it s master is your remote tracking branch we do not discuss fetch and merge here $ git pull Docs for git pull, https://git-scm.com/docs/git-pull Push send changes from the local branch to a remote repo push to the remote tracking branch $ git push Docs for git push, https://git-scm.com/docs/git-push There are many sophisticated uses of push & pull e.g. one can push to (or pull from) arbitrary branches in remote repos # 10

git Creating a Branch A branch tracks a set of (logically connected) changes no conflicts with concurrent modifications to the same part of the repo conflicts can manifest when merging two branches with overlapping changes a branch is a ref points to latest commit in corresponding branch of the commit tree In our example repo (see figure on slide #6), we start with two branches my_branch & master both initially point to the same address, 2d52a68 after changes in each branch occur separately, we see they have diverged addresses 243742d & 04d25ed respectively. Examples of using the branch command: Create new branch branch_name pointing to same address as HEAD $ git branch branch_name List local branches $ git branch Delete branch named 'branch_name' $ git branch -d branch_name Rename the branch branch_name to new name: new_branch_name $ git branch -m branch_name new_branch_name Docs for git branch, https://git-scm.com/docs/git-branch # 11

git workflow create, then merge a branch Create a new branch, named issue03 perhaps the goal is to address issue #3 from GitHub repo $ git checkout b issue03 the above is shorthand for the following two commands: $ git branch issue03 $ git checkout issue03 Add a new file to the branch (trivial example) $ touch dummy.txt $ git add dummy.txt $ git commit m this file is empty $ git push set-upstream origin issue03 Merge this branch into the master branch $ git checkout master $ git merge issue03 $ git push origin master Docs for git merge, https://git-scm.com/docs/git-merge More workflow details here, https://git-scm.com/book/en/v2/git-branching-basic-branching-and-merging # 12

Any questions at this point? Class discussion: Why would you want to create a branch? What is a ref in the world of git? Today s computer lab exercises will provide some practical experience # 13

GitHub overview GitHub & Bitbucket are two of the largest web-based hosting services they are targeted towards software development projects can be used for proposals, papers or any collection of documents neither supports Subversion (SVN) GitHub exclusively supports git; Bitbucket supports git and mercurial GitHub provides the following features (and more): an integrated issue tracker branch comparison views native applications for Windows and Mac desktops https://desktop.github.com/ support for over 200 programming languages and data formats GitHub pages, a feature for publishing and hosting SSL, SSH & https for data transmission; two-factor authentication for login API integration for 3 rd -party tool and other platforms partial support is provided for SVN import SVN repos into git for a comparison, see https://www.upguard.com/articles/github-vs-bitbucket GitHub repos can be cloned directly via the SVN client. # 14

The GitHub issues feature Creating issues is a good thing most other tracking systems call them tickets every GitHub repo has it s own set of issues Issues help you (or a team) keep track of tasks, enhancements and bugs They are a very good alternative to email they can be shared and discussed with the team individuals can turn notifications on/off they can be closed and later re-opened provides a searchable archive Docs for GitHub issues, https://guides.github.com/features/issues/ # 15

An example GitHub code repository rsbeams is a python library for 3D particle beams rsbeams: https://github.com/radiasoft/rsbeams not specific to any particular tracking code rsbeams is used by other Python libraries, which are code specific rswarp: https://github.com/radiasoft/rswarp rssynergia: https://github.com/radiasoft/rssynergia In the Computer Lab this afternoon & tomorrow, you will fork this repo to your own GitHub account clone this forked repo to your laptop or desktop decide what part of the code you would like to test create an issue in the original repo regarding your plan to create a test create a branch in your working directory create/add/commit the test in your branch merge your branch into the master branch of your forked repo on GitHub Issue a pull request to the original repository We won t cover all this material today # 16

An overview of the rsbeams repository # 17

Wrap up Any final questions regarding the material in this lecture? In the Computer Lab this afternoon, you will fork this repo to your own GitHub account clone this forked repo to your laptop or desktop document each of the following with an issue: run the existing tests create a branch create a new example, based on one of the existing tests merge the branch back into master decide what part of the code you would like to test create an issue in the original repo regarding your plan to create a test # 18