Lecture 4 Branches Sign in on the attendance sheet!

Slides:



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

Version Control CS440 – Introduction to Software Engineering © 2014 – John Bell Based on slides prepared by Jason Leigh for CS 340 University.
Git : Part3 Branch Management These slides were largely cut-and-pasted from tutorial/, with some additions.
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.
Introduction to git Alan Orth Nairobi, Kenya September, 2010 version control for serious hackers ;)
2/6/2008Prof. Hilfinger CS164 Lecture 71 Version Control Lecture 7.
Using subversion COMP 2400 Prof. Chris GauthierDickey.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
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
1 CSE 390 “Lecture 11” Version control with Git slides created by Ruth Anderson, images from
BIT 285: ( Web) Application Programming Lecture 07 : Tuesday, January 27, 2015 Git.
Git: Part 1 Overview & Object Model These slides were largely cut-and-pasted from tutorial/, with some additions.
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
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.
Subversion. What is Subversion? A Version Control System A successor to CVS and SourceSafe Essentially gives you a tracked, shared file system.
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.
Branching. Version Control - Branching A way to write code without affecting the rest of your team Merge branches to integrate your changes.
ITEC 370 Lecture 16 Implementation. Review Questions? Design document on F, feedback tomorrow Midterm on F Implementation –Management (MMM) –Team roles.
Drexel University Software Engineering Research Group Git for SE101 1.
Version Control. How do you share code? Discussion.
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
SWEN 302: AGILE METHODS Roma Klapaukh & Alex Potanin.
Information Systems and Network Engineering Laboratory II DR. KEN COSH WEEK 1.
CVS – concurrent versions system Network Management Workshop intERlab at AIT Thailand March 11-15, 2008.
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.
By: Anuj Sharma. Topics covered:  GIT Introduction  GIT Benefits over different tools  GIT workflow  GIT server creation  How to use GIT for first.
A Simple Introduction to Git: a distributed version-control system CS 5010 Program Design Paradigms “Bootcamp” Lesson 0.5 © Mitchell Wand, This.
Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand.
1 © 2015 Albion College | BUGMI 2015 Git’s Architecture And How It Relates to Banner Eddie Bachle Albion College September 25, 2015.
Version Control with Git xkcd.com/1597.
1 Web Design Workshop DIG 4104c – Lecture 5c Git: Branch and Merge J. Michael Moshell University of Central Florida giantteddy.com.
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
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.
© 2015 by Herb Holyst Introduction to git Cytomics Workshop December, 2015.
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.
Lecture 5 Remotes Sign in on the attendance sheet! Turn in homework at the front!
1 Ivan Marsic Rutgers University LECTURE 2: Software Configuration Management.
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 workflows: using multiple branches for parallel development SE-2800 Dr. Mark L. Hornick 1.
Information Systems and Network Engineering Laboratory II
Sign in on the attendance sheet!
11 Version control (part 2)
LECTURE 2: Software Configuration Management
Version Control.
Git Practice walkthrough.
Sign in on the attendance sheet!

A Simple Introduction to Git: a distributed version-control system
CSE 303 Concepts and Tools for Software Development
Git branches and remotes
Software Engineering for Data Scientists
Sign in on the attendance sheet!
Akshay Narayan git up to speed with RCS Akshay Narayan
LECTURE 3: Software Configuration Management
Advantages Project Career Divide & Conquer Collaboration
GitHub 101 Using Github and Git for Source Control
Git Fundamentals.
Git Introduction.
Presentation transcript:

Lecture 4 Branches Sign in on the attendance sheet!

Scenario: You work on two features at once in a project b4e2c29: initial commit b5f3729: even more work on feature A 8277e09: even more work on feature B 8b7d883: begin work on feature B 8fc42c6: begin work on feature A 6f96cf3: more work on feature A e167179: more work on feature B master, HEAD

Scenario: You work on two features at once in a project b4e2c29: initial commit b5f3729: even more work on feature A 8277e09: even more work on feature B 8b7d883: begin work on feature B 8fc42c6: begin work on feature A 6f96cf3: more work on feature A e167179: more work on feature B master, HEAD -Hard to distinguish the two different features that are being worked on based on the git history -If the features are related, the commits might interfere with each other

Solution: Non-linear development via branches 8b7d883: begin work on feature B 8fc42c6: begin work on feature A 6f96cf3: more work on feature A e167179: more work on feature B b4e2c29: initial commit b5f3729: even more work on feature A 8277e09: even more work on feature B master featureA featureB, HEAD

git branch Example use: git branch Lists all the local branches in the current repository and marks which branch you’re currently on Where are “you”? Well, you’re always at HEAD. Usually, you’re also at a branch as well.

git branch Example use: git branch develop Creates a new branch called “develop” that points to wherever you are right now (i.e. wherever HEAD is right now)

git checkout Example use: git checkout develop Switches to the branch named “develop” Instead of a branch name, you can also put a commit hash Very different from “git checkout <filename” (from last week)! That checkouts a single file, this checkouts the entire branch, including all of its files

git checkout -b Example use: git checkout –b develop Creates a new branch called “develop” pointing to wherever you are right now, then switches over to it Essentially “git branch ” followed by “git checkout ”

Commits are made on whatever branch you’re on B A CDEF master experiment wildidea badidea, HEAD git commit –m “A” git commit –m “B” git branch experiment git checkout experiment git commit “C” git commit “D” git checkout –b “wildidea” git commit “E” git checkout –b “badidea” git commit “F”

Commits are made on whatever branch you’re on B A CDEF master experiment wildidea badidea, HEAD git commit –m “A” git commit –m “B” git branch experiment git checkout experiment git commit “C” git commit “D” git checkout –b “wildidea” git commit “E” git checkout –b “badidea” git commit “F” Note: Branches are just pointers!

Exercise: What [directed, acyclic] graph do the following git commands produce? git commit –m “A” git commit –m “B” git branch stable git checkout –b experiment git commit –m “C” git checkout master git commit –m “D” git branch goodidea git checkout experiment git branch whereami git commit –m “E” git checkout goodidea git checkout master git commit –m “F” git checkout whereami git commit –m “G” git checkout master

git commit –m “A” git commit –m “B” git branch stable git checkout –b experiment git commit –m “C” git checkout master git commit –m “D” git branch goodidea git checkout experiment B A CDEF stable experiment goodidea master, HEAD G whereami git branch whereami git commit –m “E” git checkout goodidea git checkout master git commit –m “F” git checkout whereami git commit –m “G” git checkout master Exercise: What [directed, acyclic] graph do the following git commands produce?

What branch am I on if I checkout some commit’s hash? B A CDEF stable experiment goodidea master G whereami git checkout 6bfb021 (pretend this is C’s hash) HEAD

How do we bring branches back together? 8b7d883: Bob: begin work on feature B 8fc42c6: Alice: begin work on feature A 6f96cf3: Alice: more work on feature A e167179: Bob: more work on feature B b4e2c29: initial commit b5f3729: Alice: even more work on feature A 8277e09: Bob: even more work on feature B master featureA featureB, HEAD

How do we bring branches back together? 8b7d883: Bob: begin work on feature B 8fc42c6: Alice: begin work on feature A 6f96cf3: Alice: more work on feature A e167179: Bob: more work on feature B b4e2c29: initial commit b5f3729: Alice: even more work on feature A 8277e09: Bob: even more work on feature B master, HEAD featureA featureB db82ca7: Merge branch ‘featureA’ into master

How do we bring branches back together? 8b7d883: Bob: begin work on feature B 8fc42c6: Alice: begin work on feature A 6f96cf3: Alice: more work on feature A e167179: Bob: more work on feature B b4e2c29: initial commit b5f3729: Alice: even more work on feature A 8277e09: Bob: even more work on feature B master, HEAD featureA featureB db82ca7: Merge branch ‘featureA’ into master

git merge Example use: git merge featureA Makes a new commit on the CURRENT branch that brings in changes from featureA

How does git know how to merge changes from another branch into yours?

It doesn’t.

Most cases: Merging with possible conflicts B A CDEF goodidea master, HEAD Let’s say I’m on master (as denoted by HEAD) and I want to merge goodidea into master. git merge goodidea

Most cases: Merging with possible conflicts B A CDEF goodidea master, HEAD Let’s say I’m on master (as denoted by HEAD) and I want to merge goodidea into master. git merge goodidea At this point, if bringing in all the changes from goodidea do not conflict with the files in master, then a new commit is created (you’ll have to specify a commit message) and we’re done. Otherwise…git just goes halfway and stops. G master, HEAD

MERGE CONFLICT B A CDEF goodidea master, HEAD G

“How to fix a merge conflict” Run `git status` to find the files that are in conflict. For each of these files, look for lines like “ >>>>> 3de67ca” that indicate a conflict. Edit the lines to match what you want them to be. After you finish doing this for each conflict in each file, `git add` these conflicted files and run `git commit` to complete the merge.

Special Case: Fast-forward merges B A CDEF master, HEAD experiment wildidea badidea

Special Case: Fast-forward merges B A CDEF HEAD, master, experiment wildidea badidea master, HEAD Git doesn’t bother creating another commit to combine the changes because this kind of merge is guaranteed to not have conflicts.

Special Case: Fast-forward merges B A CDEF master, HEAD wildidea badidea G experiment Some people like creating a new commit anyway to document the fact that the merge occurred. To do so, do git merge –no-ff

Summary git branch – list all branches git branch - make a new branch git checkout - switch to another branch or commit git checkout –b - do both of the above in one step git merge - make a commit merging in a branch