Version Control with Git

Slides:



Advertisements
Similar presentations
An Introduction By Sonali and Rasika.  Required for the project  Show the versions of your code in the course of development  Show versions of your.
Advertisements

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.
Git A distributed version control system 23-Aug-15.
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
Introduction to Git and Github Joshua imtraum.com.
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 ▪Version control is a system that records changes to a file or set of files over time so.
Peter Ogden and Josh Levine.  Motivation  High level overview  Walk through the common operations  How not to break things (too badly)
Git – versioning and managing your software L. Grewe.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 8-Oct-15.
Version control Using Git Version control, using Git1.
Version Control Systems academy.zariba.com 1. Lecture Content 1.What is Software Configuration Management? 2.Version Control Systems (VCS) 3.Basic 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.
Object-Oriented Analysis & Design Subversion. Contents  Configuration management  The repository  Versioning  Tags  Branches  Subversion 2.
Team 708 – Hardwired Fusion Created by Nam Tran 2014.
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.
Version Control Systems. Version Control Manage changes to software code – Preserve history – Facilitate multiple users / versions.
Sofia Event Center May 2014 Martin Kulov Git For TFS Developers.
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.
Information Systems and Network Engineering Laboratory I DR. KEN COSH WEEK 1.
INTRODUCTION TO GIT. Install Egit for eclipse Open eclipse->Help->Install New Software Search for one of the following -
1 Ivan Marsic Rutgers University LECTURE 2: Software Configuration Management.
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.
Jun-Ru Chang Introduction GIT Jun-Ru Chang
Backing up a machine with git
Source Control Dr. Scott Schaefer. Version Control Systems Allow for maintenance and archiving of multiple versions of code / other files Designed for.
KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association STEINBUCH CENTRE FOR COMPUTING - SCC
Dr. Tanusri Bhattacharya
Basics of GIT for developers and system administrators
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to Version Control with Git
M.Sc. Juan Carlos Olivares Rojas
4 Version control (part 1)
Information Systems and Network Engineering Laboratory II
Discussion #11 11/21/16.
I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson
Git and GitHub primer.
LECTURE 2: Software Configuration Management
Source Control Dr. Scott Schaefer.
Discussion 11 Final Project / Git.
Version Control with Subversion (SVN)
Version control, using Git
File Version Control System

CS5220 Advanced Topics in Web Programming Version Control with Git
Git branches and remotes
Software Engineering for Data Scientists
Concurrent Version Control
An introduction to version control systems with Git
Version Control with Git accelerated tutorial for busy academics
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
An introduction to version control systems with Git
(Advanced) Web Application Development
Version Control with git
LECTURE 3: Software Configuration Management
The Big Picture
An introduction to version control systems with Git
Subversion Basics Guide
Version Control System - Git
Version control with Git
Version Control with Git and GitHub
Version Control with Git
Version/revision control via git
Git GitHub.
Introduction to The Git Version Control System
Presentation transcript:

Version Control with Git http://flic.kr/p/6oP7x7 Version Control with Git

Why track/manage revisions?

Backup: Undo or refer to old stuff http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

Branch: Maintain old release while working on new http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

Collaborate: Work in parallel with teammates http://git-scm.com/book/en/Distributed-Git-Distributed-Workflows

Version Control Systems (VCSs) Help you track/manage/distribute revisions Standard in modern development Examples: Revision Control System (RCS) Concurrent Versions System (CVS) Subversion (SVN) Git older Our focus newer

GitHub-User Perspective You GitHub Working Dir Local Repos Remote Repos

Let’s begin with an example… You GitHub

Configure your Git client (Rails Tutorial 1.3.1) Install Git Check config info: Fix if necessary: $ git config --list user.name=Scott Fleming user.email=Scott.Fleming@memphis.edu $ git config --global user.name "John Doe" $ git config --global user.email jdoe@memphis.edu

Log into GitHub and create a repos (with add README option) You GitHub Remote Repos

$ git clone https://github.com/sdflem/comp4081_demo.git You GitHub Local Repos Working Dir Remote Repos

You GitHub Working Dir Local Repos Remote Repos $ rails new comp4081_demo You GitHub Local Repos Working Dir Remote Repos

You GitHub Working Dir Local Repos Remote Repos $ cd comp4081_demo $ git add -A $ git commit –m "Created Rails project skeleton" You GitHub Local Repos Working Dir Remote Repos

$ git push You GitHub Local Repos Working Dir Remote Repos

Questions to answer How organized? You GitHub What operations? Local Repos Working Dir Remote Repos What operations?

How the repos is organized http://git-scm.com/book/

How the repos is organized Commits (from oldest to newest; hashes as commit IDs) http://git-scm.com/book/

How the repos is organized Snapshot of all files at each commit http://git-scm.com/book/

How the repos is organized Branch (last commit) http://git-scm.com/book/

How commit works Before http://git-scm.com/book/

How commit works After http://git-scm.com/book/

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos Make changes in local branch Merge with GitHub repos

Organization with two branches

Organization with two branches Last commit of each branch

Organization with two branches Currently checked out branch

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git branch works $ git branch testing Before

How git branch works $ git branch testing After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git checkout works $ git checkout testing Before

How git checkout works $ git checkout testing After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git commit works with multiple branches Edit some stuff $ git add -A $ git commit –m "blah" Before

How git commit works with multiple branches Edit some stuff $ git add -A $ git commit –m "blah" After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git checkout works $ git checkout master Before

How git checkout works $ git checkout master After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git pull works Someone else pushed $ git pull Before

How git pull works Someone else pushed $ git pull After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git merge works $ git merge testing Before

How git merge works $ git merge testing e2b92 After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How to delete branches $ git branch -d testing e2b92 Before

How to delete branches $ git branch -d testing e2b92 After

Common Workflow Create temp local branch Checkout temp branch Edit/Add/Commit on temp branch Checkout master branch Pull to update master branch Merge temp branch with updated master Delete temp branch Push to update server repos

How git push works Should update server repos $ git push e2b92 Should update server repos (if no one else has pushed commits to master branch since last pull)

Tips git output contains lots of hints git status is your friend! Merging may not be as easy as I showed E.g.: Multiple collabs updated same parts of file See Pro Git 3.2 Pull before starting temp branch Team communication important!

Pop Quiz 5 questions Update diagram in each Commit nodes Branch nodes Based on actions of Alice and Bob Collaborating via GitHub repo

Start like this Scott Fleming SF 1 GitHub 11111 master Alice Bob

Question 1 Alice: Bob: (include the HEAD node) $ git clone https://github.com/whatever.git $ cd whatever Bob: (include the HEAD node)

Question 2 Alice: (Alternatively) $ git branch myfix $ git checkout myfix (Alternatively) $ git checkout -b myfix

Question 3 Alice: Bob: $ rails generate scaffold User … $ git add -A $ git commit -m "Added User" # 22222 Bob: $ rails generate scaffold Micropost … $ git commit -m "Added Micropost" # 33333

Question 4 Bob: git push

Question 5 Alice: git pull

Appendix

What if… Alice did this: Bob did this: app/models/micropost.rb class Micropost < ActiveRecord::Base validates :content, length: { maximum: 140 } end app/models/micropost.rb Bob did this: class Micropost < ActiveRecord::Base validates :content, length: { maximum: 120 } end app/models/micropost.rb

What if Alice did this? $ git checkout master $ git merge myfix master 11111 master 22222 33333 myfix $ git checkout master $ git merge myfix

Manually fix the file; git add and commit $ git merge myfix Auto-merging app/models/micropost.rb Automatic merge failed; fix conflict and then commit result. class Micropost < ActiveRecord::Base <<<<<<< HEAD validates :content, length: { maximum: 140 } ======= validates :content, length: { maximum: 120 } >>>>>>> myfix end app/models/micropost.rb To resolve: Manually fix the file; git add and commit