CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 16 – Version control and git.

Slides:



Advertisements
Similar presentations
1. What is Subversion? Why do we need CM? Basic concepts Repositories Options Setup Clients Options Setup Operation Troubleshooting Slide 2.
Advertisements

Simple Git Steve Pieper. Topics Git considerations and Slicer Git as if it were svn Git the way it is meant to be.
David Notkin Autumn 2009 CSE303 Lecture 22 Subversion is an open source version control system. Social Implications Friday version control system.
2/6/2008Prof. Hilfinger CS164 Lecture 71 Version Control Lecture 7.
Using subversion COMP 2400 Prof. Chris GauthierDickey.
Version Control Systems Phil Pratt-Szeliga Fall 2010.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
G51FSE Version Control Naisan Benatar. Lecture 5 - Version Control 2 On today’s menu... The problems with lots of code and lots of people Version control.
Version Control with git. Version Control Version control is a system that records changes to a file or set of files over time so that you can recall.
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
Introduction to Git and Github Joshua imtraum.com.
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Distributed Version Control. Image stolen from which is really good, go read it.  Old-school version control.
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
Getting Started with GIT. Basic Navigation cd means change directory cd.. moves you up a level cd dir_name moves you to the folder named dir_name A dot.
Version Control with Subversion. What is Version Control Good For? Maintaining project/file history - so you don’t have to worry about it Managing collaboration.
Chapter - 2 What is “GIT” VERSION CONTROL AND GIT BASICS.
Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
Introduction to Version Control
Why you should be using Version Control. Matt Krass Electrical/Software Engineer November 22, 2014.
With Mercurial and Progress.   Introduction  What is version control ?  Why use version control ?  Centralised vs. Distributed  Why Mercurial ?
Git – versioning and managing your software L. Grewe.
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 8-Oct-15.
Warmup A programmer’s wife tells him, “Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.” The programmer.
Version Control. What is it? Software to help keep track of changes made to files Tracks the history of your work Helps you collaborate with others.
Git workflow and basic commands By: Anuj Sharma. Why git? Git is a distributed revision control system with an emphasis on speed, data integrity, and.
SWEN 302: AGILE METHODS Roma Klapaukh & Alex Potanin.
Information Systems and Network Engineering Laboratory II DR. KEN COSH WEEK 1.
Version Control.
Copyright © 2015 – Curt Hill Version Control Systems Why use? What systems? What functions?
Computer Science and Engineering The Ohio State University  Widely used, especially in the opensource community, to track all changes to a project and.
CVS – concurrent versions system Network Management Workshop intERlab at AIT Thailand March 11-15, 2008.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
CSE 219 Computer Science III CVS
Introduction to Version Control with Git CSC/ECE 517, Fall 2014 A joint project of the CSC/ECE 517 staff, including Titus Barik, Gaurav Tungatkar, Govind.
1 GIT NOUN \’GIT\ A DISTRIBUTED REVISION CONTROL AND SOURCE CODE MANAGEMENT (SCM) SYSTEM WITH AN EMPHASIS ON SPEED. INITIALLY DESIGNED AND DEVELOPED BY.
A Simple Introduction to Git: a distributed version-control system CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.5 © Mitchell Wand, This.
1 CSE306 Operating Systems Projects CVS/SSH tutorial.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
12 CVS Mauro Jaskelioff (originally by Gail Hopkins)
Version Control and SVN ECE 297. Why Do We Need Version Control?
Lecture 2 Making Simple Commits Sign in on the attendance sheet! credit:
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
1 CSE 303 Lecture 19 Version control and Subversion ( svn ) slides created by Marty Stepp
An Introduction to Git David Johndrow COMP 490 – Senior Design & Development 2/11/16.
Subversion (SVN) Tutorial for CS421 Dan Fleck Spring 2010.
It’s not just an insult from Harry Potter!. What is Git? Distributed Version Control System (DVCS) – Compared to a Centralized Version Control System.
Information Systems and Network Engineering Laboratory I DR. KEN COSH WEEK 1.
Using Git with collaboration, code review, and code management for open source and private projects. & Using Terminal to create, and push commits to repositories.
1 Subversion Kate Hedstrom April Version Control Software System for managing source files –For groups of people working on the same code –When.
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
L – Modeling and Simulating Social Systems with MATLAB
CReSIS Git Tutorial.
CSE 374 Programming Concepts & Tools
Discussion 11 Final Project / Git.
Version Control overview
CSE 303 Concepts and Tools for Software Development
Storing, Sending, and Tracking Files Recitation 2
Version Control System
Version Control with Git accelerated tutorial for busy academics
Distributed Version Control with git
Git CS Fall 2018.
Version control with Git
Version Control with Git and GitHub
Presentation transcript:

CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 16 – Version control and git

Where we are Learning tools and concepts relevant to multi-file, multi-person, multi-platform, multi-month projects Today: Managing source code –Reliable backup of hard-to-replace information (i.e., sources) –Tools for managing concurrent and potentially conflicting changes from multiple people –Ability to retrieve previous versions Note: None of this has anything to do with code. Like make, version-control systems are typically not language-specific. –Many people use version control systems for everything they do (code, papers, slides, letters, drawings, pictures,... ) Traditional systems were best at text files (comparing differences, etc.); newer ones work fine with others too –But be sure to check before storing videos & other media 2

Version-control systems There are plenty: sccs, rcs, cvs (mostly historical); subversion, git, mercurial, perforce, sourcesafe, … Terminology and commands aren’t particularly standard, but once you know one, the others aren’t difficult – the basic concepts are the same svn still is widely used – single central repository git and mercurial: distributed version control –Same core ideas, but every user has a copy of the repository; allows easy branching & merging for large collaborations (e.g., linux kernel) –We’ll use git, which is very popular these days 3

What is git? If that doesn’t fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of “It’s really pretty simple, just think of branches as…”; and eventually you’ll learn the commands that will fix everything. 4

Git basics – general version A project lives in a repository Each user has their own copy of the repository A user commits changes to her copy to save them Other users can pull changes from that repository 5

Git basics – central repo (we’ll use) Users have a shared repository (called origin in the git literature, for cse374 it is your group’s repository on the CSE GitLab server) Each user clones the repository Users commit changes to their local repository (clone) To share changes, push them to GitLab after verifying them locally Other users pull from Gitlab to get changes (instead of from each other) 6

Tasks Learn the common cases; look up the uncommon ones. In a production shop using git… Create –a new repository/project (rare – once or twice a year) –a new branch (days to weeks; not in cse374, but used in production shops for independent development) –a new commit (daily or more, each significant change) Push to repo –regularly, when you want to back up or share work – even with yourself on a different computer Other operations as needed (check version history, differences, …) 7

Repository access A repository can be: Local: specify repository directory root via a regular file path name url (file:///path...) Remote: lots of remote protocols supported (ssh, https, …) depending on repository configuration –Specify user-id and machine –Usually need gitand ssh installed locally –Need authentication (use ssh key with GitLab) cse374/HW6 use ssh access to remote GitLab server Feel free to experiment with private, local repos or private repos on gitlab 8

Getting started (GitLab) Create local ssh keys (ssh keygen) and add to your GitLab account (won’t have to type passwords once this is done & only need to do it once) Set up a repository (we’ll do this for you on hw6; if you do it yourself you get to pick name, location) +New Project (on gitlab dashboard) Clone a working copy of the repo to your machine cd where-you-want-to-put-it git clone –url for above comes from gitlab page for your project 9

Routine git/GitLab local use Edit a file, say stuff.c Add file(s) to set to be saved in repo on next commit git add stuff.c Commit all added changes git commit –m “reason/summary for commit” Repeat locally until you want to push accumulated commits to GitLab server to share with partner or for backup… 10

git/GitLab use (sharing changes) Good practice – grab any changes on server not yet in local repo git pull –Also do this any time you want to merge changes pushed by your partner Test, make any needed changes, do git add / git commit to get everything cleaned up locally When ready, push accumulated changes to server git push If push blocks because there are newer changes on server, do a git pull, accept any merge messages, cleanup, add/commit/push again 11

File rename/move/delete Once files have been committed to gitlab repository, need to tell git about any changes desired to git- managed files git mv files git rm files –git will make the changes locally then make corresponding changes to remote GitLab repo when you push –If you use regular shell mv/rm commands, git will give you all sorts of interesting messages when you run git status and you will have to clean up 12

Demo 13

Some examples Update local copy to match GitLab copy git pull Make changes git add file.c git mv oldfile.c newfile.c git rm obsolete.c Commit changes to local repo git commit –m “fixed bug in getmem” Examine changes git status (see uncommitted changed files, will also show you how to revert changes, etc.) git diff (see uncommitted changes in files) git log (see history of commits) Update GitLab copy to reflect local changes git push 14

Conflicts This all works great if there is one working copy. But if two users make changes to their own local copies, the two versions must be merged –git will merge automatically when you do a “git pull” –Usually successful if different lines or different files changed If git can’t automatically merge, you need to fix manually –git will tell you which files have conflicts (git status) –Look in files, you will see things like <<<<<<<< HEAD for (int i=0; i<10; i++) =============== for (int i=0; i<=10; i++) >>>>>>>> master –Change these lines to what you actually want, then add/commit the changes (and push if you want to) 15

git gotchas Do not forget to add/commit/push files or your group members will be very unhappy Keep in the repository exactly (and only) what you need to build the application! –Yes: foo.c foo.h Makefile –No: foo.o a.out foo.c~ –You don’t want versions of.o files etc.: Replaceable things have no value They change a lot when.c files change a little Developers on other machines can’t use them A simple.gitignore file can be used to tell git which sorts of files should not be tracked (*.o, *~,.DS_Store (OS X) ) –Goes in top-level repo directory; useful to push to GitLab and share 16

Summary Another tool for letting the computer do what it’s good at: –Much better than manually ing files, adding dates to filenames, etc. –Managing versions, storing the differences –Keeping source-code safe –Preventing concurrent access, detecting conflicts git/Gitlab tutorial for CSE 374 on website Links to GitLab on website and in CSE 374 tutorial Full git docs and book are online, free, downloadable –Beware of complexity – much of what they describe is beyond what we need for CSE 374; keep it simple 17