Introduction to Version Control with Git

Slides:



Advertisements
Similar presentations
Introduction To GIT Rob Di Marco Philly Linux Users Group July 14, 2008.
Advertisements

Simple Git Steve Pieper. Topics Git considerations and Slicer Git as if it were svn Git the way it is meant to be.
Git Branching What is a branch?. Review: Distributed - Snapshots Files are stored by SHA-1 hash rather than filename Stored in git database in compressed.
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
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 Using Git 1Version control, using Git.
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.
Git. What’s Git? A British swear A Distributed Version Control System Developed in 2005 by Linus Torvalds for use on the Linux Kernel Git Logo by Jason.
Introduction to Version Control with SVN & Git CSC/ECE 517, Fall 2012 Titus Barik & Ed Gehringer, with help from Gaurav.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
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.
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.
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.
GIT.
Intro to Git presented by Brian K. Vagnini Hosted by.
Page 1 TBD 12/08/2014 Formation GIT Laurent Kappel Groupe SII 65, rue de Bercy Paris Tél : Fax :
Version Control and SVN ECE 297. Why Do We Need Version Control?
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 - Chirag Dani. Objectives Basics of Git Understanding different “Mindset of Git” Demo - Git with Visual Studio.
Git How to 1. Why Git To resolve problems in lab exams (accidental deletions) Use existing Libraries with ease (Statistics and Computer) Prepare undergraduates.
1 Ivan Marsic Rutgers University LECTURE 2: Software Configuration Management.
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Git workflows: using multiple branches for parallel development SE-2800 Dr. Mark L. Hornick 1.
Git A distributed version control system Powerpoint credited to University of PA And modified by Pepper 28-Jun-16.
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
Basics of GIT for developers and system administrators
CS5220 Advanced Topics in Web Programming Version Control with Git
4 Version control (part 1)
Information Systems and Network Engineering Laboratory II
Primož Gabrijelčič Git for Programmers Primož Gabrijelčič
Version Control Systems
11 Version control (part 2)
SVN intro (review).
LECTURE 2: Software Configuration Management
Git Practice walkthrough.
Discussion 11 Final Project / Git.
Version Control with Subversion (SVN)
Version control, using Git
Version Control System using Git
Git branches and remotes
Software Engineering for Data Scientists
Version Control System
Akshay Narayan git up to speed with RCS Akshay Narayan
Version Control with git
LECTURE 3: Software Configuration Management
The Big Picture
Git CS Fall 2018.
Version Control System - Git
Version control with Git
Introduction to Version Control with Git
Version Control with Git
Version Control with Git and GitHub
Git Fundamentals.
Version/revision control via git
Git Introduction.
Presentation transcript:

Introduction to Version Control with Git CSC/ECE 517, Spring 2017 A joint project of the CSC/ECE 517 staff, including Titus Barik, Gaurav Tungatkar, Govind Menon, and Krunal Jhaveri 1

Local version control: RCS check out File Version 3 Version 2 Keep many copies of files Error prone RCS stores deltas Version 1 2

Centralized Version Control If you need to work with other programmers … Computer A File check out Version 3 Computer B Version 2 File check out Version 1 3

File Server vs. Version-Control Server At first glance, the client-server architecture of a version-control system looks much like a typical file server. So why do we need version control? Mininum needs: check code in/out, see history Why do we need version control? Permissions: You don’t have very good control over who can modify a file Responsibility: If there’s a bug, how do you know who cause it? VCSs have “blame” command (who last wrote a line) You may want to revert to an earlier version. Overlapping edits 4 4

File-Sharing Issues The problem is that users are stepping on each other’s feet! Image: Version Control with Subversion 5

Approach 1: Lock, Modify, Unlock Locking may cause administrative problems. Locking may cause unnecessary serialization. Locking may create a false sense of security. If someone locks a file & leaves for the weekend, forgetting to unlock it. Admin needs to unlock it, but would rather not. Developers can’t work on different parts of the same file. Locks may have dependencies. A change to file B may also require a change to file A. Can cause deadlock. Image: Version Control with Subversion 6

Approach 2: Copy-Modify-Merge Sounds chaotic, but in practice, runs extremely smoothly. Question: When is locking necessary? Where wouldn’t copy-merge-modify work well, & you would still need locking? Consider editing a binary file, like audio. Ditto for images. Image: Version Control with Subversion 7

Exercise 1 Answer these questions Give one advantage of using a version-control server for source-code management over using a fileserver. Explain how locking can cause administrative problems. Explain how locking can create a false sense of security. With copy-modify-merge, when is locking necessary? These questions should be fixed … # of interactions is useless. 8 8

Branches and Tags Trunk: Location where main development occurs. Branches: Location used to isolate changes to another development line (e.g., experimental features). Tags: Snapshot of the content (e.g., RTM, service packs, EOL). If branches work well, they should be merged back into the main project. RTM: Release to mfg. (or mktg.) Image: http://en.wikipedia.org/wiki/Subversion_(software) 9 9

Traditional Repository Format A Subversion repository layout—typical of older version-control systems. The folder names are just a convention, and have no special meaning to the repository. Image: Version Control with Subversion 10

Creating a Branch—by Copying In Subversion, the underlying mechanism of a branch is implemented by performing a simple directory copy. Image: Version Control with Subversion 11

Exercise 2 Answer these questions about branches. Suppose, in fixing a bug, you modify three lines of code in two source files. Should you create a new branch? Why or why not? Which would probably be more common, branches or tags? What are some of the risks of copying files in a repository? How do version-control systems minimize this risk? Questions seem to be OK; could possibly add to them. 12

Distributed Version Control Clients don’t check out individual files; they mirror the repository. What’s the advantage? Computer A Computer B File File Version 3 Version 2 Version 1 Version 3 Version 2 Version 1 13

Git Came out of the Linux project, in 2005. Simple design Strong support for non-linear development (thousands of parallel branches) Fully distributed Able to handle large projects like the Linux kernel efficiently (speed and data size) 14

Integrity & Checksums Everything checksummed with an SHA-1 hash 40-character string composed of hex characters calculated based on the contents of a file or directory structure in Git Example 24b9da6552252987aa493b52f8696cd6d3b00373 But, you don’t have to type the whole SHA … Git knows everything by hash, not filename 15

Snapshots, not Diffs See http://git-scm.com/book/ch1-3.html Every time you commit, Git takes a snapshot of your files. Files that have not changed are not copied.  Almost all ops are local browse history commit 16

git directory (repository) 3 States of a File in Git Modified • Staged • Committed working directory staging area git directory (repository) check out the project stage files commit 17

File Status Lifecycle edit the file add the file stage the file untracked unmodified modified staged edit the file add the file stage the file remove the file 18

Checking Status To check the status of your files: $ git status # On branch master nothing to commit (working directory clean) Creating new files $ vim README $ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track) Have them do an example with “git add”. 19

Checking status, cont. Begin to track the file: $ git add README The file is now tracked: $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: README # For more info: http://git-scm.com/book/ch2-2.html 20

Remotes On a project, you may be working with several remote directories. “Origin” is the server you cloned your repository from $ git clone git://github.com/schacon/ticgit.git Initialized empty Git repository in /private/tmp/ticgit/.git/ remote: Counting objects: 595, done. remote: Compressing objects: 100% (269/269), done. remote: Total 595 (delta 255), reused 589 (delta 253) Receiving objects: 100% (595/595), 73.31 KiB, done. Resolving deltas: 100% (255/255), done. $ cd ticgit $ git remote origin http://git-scm.com/book/ch2-5.html 21

Pulling, pushing to remote $ git fetch [remote-name] E.g., git fetch origin git push origin master 22

Common Workflow using Git Centralized workflow … http://git-scm.com/book/ch5-1.html 23

Common Workflow using Git Integration-manager workflow … Common use cases: http://git-scm.com/book/ch5-2.html 24

Pull requests After you’ve finished a project, you need to notify the maintainer. This is done via a pull request. You say which repository to pull from, and give a summary of your changes. http://git-scm.com/book/ch5-2.html We might add more background info on why this is useful … 25

Guidelines for Commits What happens if you download a repo in a zip file, do your project, then save it with a single commit? (Think of someone else trying to merge your changes with another programmer’s changes.) This can be fleshed out … 26

Your code Repository code Is the difference because— … a = a + b … a = c Is the difference because— you changed a = c to a = a + b, or because someone else changed a = a + b to a = c while you were working on your project? 27

Guidelines for Commits Which is worse, Downloading the repo as a zip file, and being scrupulously careful to make multiple commits with reasonable commit comments, or Downloading the repo with its commit history, but committing your whole project in one commit? Why? Of course, you shouldn’t do either! + pulling in commits from other branches + mergetools + handling conflicts 28

Guidelines for Commits In your work, save the commit history. Each commit should be on one topic. A commit comment should be 1 line, certainly no more than one sentence. 29

Exercise 3 Visit https://github.ncsu.edu/amajumd/GIT- Exercise Clone the repository using the HTTPS clone url $ git clone [https_url] // clone an existing repo $ git branch // List branches 30

Exercise 3, cont. $ git branch $ git branch [unityId] // create a new branch from the current HEAD $ git checkout [unityId] // switch to that branch 31

Exercise 3, cont. Add a new file (you can take a look at the test file and create a new test) $ git status $ git add [filename] $ git commit -m “Commit message” $ git push origin [unityId] // push on to the branch on the remote 32

Exercise 3, cont. [Pause here, until next week.] $ git fetch origin // Update other branches $ git merge origin/master //Merge any new changes on master into current branch 33

Exercise 3, cont. $ git checkout master $ git merge [unityId] // merge changes from your branch back into master 34

Exercise 3, cont. Your new branch Master branch Local Commit 1 Remote (Origin) 35

Exercise 3, cont. Your new branch Local Commit 1 Commit 1 Commit 1.5 Remote (Origin) 36

Exercise 3, cont. Master branch Local Commit 1 Commit 1 Commit 1.5 Remote (Origin) 37