Version Control Software

Slides:



Advertisements
Similar presentations
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.
Advertisements

1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
Git for Version Control These slides are heavily based on slides created by Ruth Anderson for CSE 390a. Thanks, Ruth! images taken from
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.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
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.
GIT An introduction to GIT Source Control. What is GIT (1 of 2) ▪ “Git is a free and open source distributed version control system designed to handle.
Version control Using Git Version control, using Git1.
ITEC 370 Lecture 16 Implementation. Review Questions? Design document on F, feedback tomorrow Midterm on F Implementation –Management (MMM) –Team roles.
Version Control Systems academy.zariba.com 1. Lecture Content 1.What is Software Configuration Management? 2.Version Control Systems (VCS) 3.Basic Git.
…using Git/Tortoise Git
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.
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.
Sofia Event Center May 2014 Martin Kulov Git For TFS Developers.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
CS 160 and CMPE/SE 131 Software Engineering February 16 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
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.
Introduction to Git - Chirag Dani. Objectives Basics of Git Understanding different “Mindset of Git” Demo - Git with Visual Studio.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
Getting Started with Git Presented by Jim Taylor Rooty Hollow, Owner Verizon Wireless, Senior Programmer/Analyst Git User for 6 years.
Jun-Ru Chang Introduction GIT Jun-Ru Chang
GIT Version control. Version Control Sharing code via a centralized DB Also provides for Backtracking (going back to a previous version of code), Branching.
Backing up a machine with git
GIT: (a)Gentle InTroduction Bruno Bossola. Agenda About version control Concepts Working locally Remote operations Enterprise adoption Q&A.
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association STEINBUCH CENTRE FOR COMPUTING - SCC
Dr. Tanusri Bhattacharya
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to Version Control with Git
4 Version control (part 1)
Information Systems and Network Engineering Laboratory II
I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson
Git and GitHub primer.
11 Version control (part 2)
SVN intro (review).
Git Practice walkthrough.
Version control, using Git
Git for Visual Studio Developers MARTIN KULOV, ASE
CS5220 Advanced Topics in Web Programming Version Control with Git
Version Control System using Git
Git branches and remotes
CISC/CMPE320 - Prof. McLeod
Software Engineering for Data Scientists
Version Control with Git and GitHub
Storing, Sending, and Tracking Files Recitation 2
Version Control System
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
Anatomy of a Git Project
Version Control with git
Git CS Fall 2018.
Version Control System - Git
Version control with Git
Introduction to Version Control with Git
Git started with git: 2018 edition
Version Control with Git
Version Control with Git and GitHub
GitHub 101 Using Github and Git for Source Control
Git Fundamentals.
Git Introduction.
Git GitHub.
Introduction to The Git Version Control System
Introduction To GitHub
Introduction To GitHub
Presentation transcript:

Version Control Software Step 1: Track code changes Step 2: ??? Step 3: Profit Copyright © 2018, Corey Pennycuff

Why Do We Need A VCS? VCSs Track File Changes Code is organized within a repository. VCSs Tell Us: Who made the change? So you know whom to blame What has changed (added, removed, moved)? Changes within a file Addition, removal, or moving of files/directories Where is the change applied? Not just which file, but which version or branch When was the change made? Timestamp Why was the change made? Commit messages Basically, the Five W’s Copyright © 2018, Corey Pennycuff

Brief History Of Version Control Software First Generation – Local Only SCCS – 1972 Only option for a LONG time RCS – 1982 For comparison with SCCS, see this 1992 forum link Second Generation – Centralized CVS – 1986 Basically a front end for RCS SVN – 2000 Tried to be a successor to CVS Perforce – 1995 Proprietary, but very popular for a long time Second Generation (Cont.) Team Foundation Server – 2005 Microsoft product, proprietary Good Visual Studio integration Third Generation – Decentralized BitKeeper – 2000 GNU Bazaar – 2005 Canonical/Ubuntu Mercurial – 2005 Git – 2005 Team Foundation Server – 2013 Copyright © 2018, Corey Pennycuff

Git – The Stupid Content Tracker Started by Linus Torvalds – 2005 After the BitKeeper debacle Efficient for large projects E.g., Linux Was an order of magnitude faster than other contemporary solutions Non-linear development! Branching is cheap and easy!!!! Official Site, Wikipedia, Initial README commit (some profanity) Copyright © 2018, Corey Pennycuff

Terminology Branch Commit Tag A Repository may be created by: A history of successive changes to code A new branch may be created at any time, from any existing commit May represent versions of code Version 1.x, 2.x, 3.x, etc. May Represent small bugfixes/feature development Branches are cheap Fast switching Easy to “merge” into other branches Easy to create, easy to destroy See this guide for best practices Commit Set of changes to a repository’s files More on this later Tag Represents a single commit Often human-friendly Version Numbers A Repository may be created by: Cloning an existing one (git clone) Creating a new one locally (git init) Copyright © 2018, Corey Pennycuff

What is a Commit? Specific snapshot within the development tree Collection of changes applied to a project’s files Text changes, File and Directory addition/removal, chmod Metadata about the change Identified by a SHA-1 Hash Can be shortened to approx. 6 characters for CLI use (e.g., “git show 5b16a5”) HEAD – most recent commit ORIG_HEAD – after a merge, the previous HEAD <commit>~n – the nth commit before <commit> e.g., 5b16a5~2 or HEAD~5 master@{01-Jan-2018} – last commit on master branch before January 1, 2018 Copyright © 2018, Corey Pennycuff

Branches, Commits, and Tags, Oh My! Change the API (again) f1c2b8 Add Cool Feature 1 c4d00a Add Cool Feature 2 e11bd4 Add Cool Feature 3 9e35ed Change the API fd9943 Initial Commit a2e7c0 Master (branch) 8f645f Add Stuff 9fd132 Bugfix 1 af1c2b Bugfix 2 1.x (branch) 1.0 (tag) 1.1 (tag) 619cec Add Stuff 2.x (branch) Copyright © 2018, Corey Pennycuff

Terminology Working Files The Stage (also called the “index”) Checkout Files that are currently on your File System The Stage (also called the “index”) Staging is the first step to creating a commit The stage is what you use to tell Git which changes to include in the commit File changes must be “added” to the stage explicitly Only changes that have been staged will be committed Checkout Replace the current working files with those from a specific branch or commit Use “git diff” to see which changes exist. Use “git add” to tell Git that a file’s changes should be added to the stage. Use “git status” to see the changes in your working files, as well as what changes have been staged for the commit. Use “git commit” to convert all staged changes into a commit. git commit -m “my commit message” git commit -m “my commit message” -a Will automatically stage all files tracked by the repo & add them to the commit. Please don’t do this. Copyright © 2018, Corey Pennycuff

A Distributed VCS What do we mean by distributed? Cloning a repository (repo) creates a full copy of that repo on your local machine. You can fetch updates from non-local repositories (e.g., repos on GitHub) A non-local repositories is a remote When you clone a repository, a remote called origin is created for you automatically in your local repo which points to the source repo. Remotes are local settings. They do not become part of your commits. You may set up additional remotes. Use case: Development teams, where each dev has their own repository. Common Pattern: One canonical repository for the project (on GitHub, for example) Every developer forks that repo on GitHub A fork is simply creating a copy of the repo on that remote system Every developer clones their own GitHub repo to their local machine Every developer adds a remote pointing to the canonical (main, authoritative) repo, as well as other dev repos as needed Devs work locally, push changes to their own remote, then request that the canonical repo accept their changes via a pull request. Copyright © 2018, Corey Pennycuff

A Distributed VCS (Visualized) GitHub, BitBucket, SourceForge, GitLab, CodePlex, etc. Canonical Pull Request fork main fork fork Arlene Cindy Bret origin cindy bret clone Action Remote (no push) Remote (with push) Action on GitHub Local repo *Names taken from 2017 Tropical Storms Copyright © 2018, Corey Pennycuff

Git Workflow Local You pull from a remote to your local repository. A pull is a fetch and a merge I prefer to use fetch and merge separately, and avoid pull. You push a branch from your local repository to a remote. A failure to merge is a merge conflict, and must be resolved manually. (more on next slide) Helpful list of Git Commands https://cscrunch.com/blog/corey- pennycuff/my-git-cheat-sheethandout Image by Daniel Kinzler Copyright © 2018, Corey Pennycuff

Merging A “merge” is the act of incorporating the changes from one branch or commit into a second branch. The histories do not have to match exactly; Git will work to sort them out. If a merge fails, Git will notify you of a “merge conflict”. Merge conflicts must be fixed manually, and then added and committed. “git status” will show any merge conflicts. A successful merge creates a new commit automatically. What causes a merge conflict? 2 branches modify the same place in the same file. This often happens at the end of files or between function declarations. Git does not know which version of the change you want, or if you want both of them consecutively (and in which order), so you must inspect the conflict and resolve it. If you cannot push your code to a remote, you probably need to first pull the latest changes, resolve any existing merge conflicts, then try to push again. Small commits are better than large ones! Copyright © 2018, Corey Pennycuff

Common Industry Programmer Workflow Choose a bug/feature to work on Checkout the appropriate branch Pull the latest additions from the main repository Create a branch for the bug/feature request Do the coding necessary & commit Push the changes to your remote Create a pull request to main repo The pull request is where other programmers review your code & make comments/suggestions. If changes are needed to your code, then repeat the process. Never commit directly to the main repo. Copyright © 2018, Corey Pennycuff

Practical Guidelines Do’s Don’ts Make small, incremental commits (within reason) are good. Avoid monolithic commits at all cost. Use a separate branch for each new bug/feature request. Write nice commit messages. Otherwise, the commit log is useless. Use a .gitignore to keep cruft out of your repo. Search engines are your friend. Someone else has had the same question/mistake/situation as you, and they have already asked the question online. It’s probably on StackOverflow. Don’ts Do not commit commented-out debug code. It’s messy. It’s ugly. It’s unprofessional. Do not mix your commits. (e.g., Don’t commit two bugfixes at the same time.) Do not commit sensitive information (passwords, database dumps, etc.) Do not commit whitespace differences, unless it is specifically needed. Do not commit large binaries. Copyright © 2018, Corey Pennycuff

Helpful Resources Pro Git – free Apress ebook Visualizing Git histories Wikipedia on Version Control, with definitions My Git Cheat Sheet Git Commit Etiquette for Junior Devs https://www.codeschool.com/learn/git Free course to walk you through basic Git concepts Copyright © 2018, Corey Pennycuff