Git branches and remotes

Slides:



Advertisements
Similar presentations
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.
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.
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
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.
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.
علیرضا فراهانی استاد درس: جعفری نژاد مهر Version Control ▪Version control is a system that records changes to a file or set of files over time so.
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 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.
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.
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
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: What, how and why ? Part 1: Basics. What do I know about git? Started using it for experiments on April 2009 Moved all voms development on git on.
Git How to 1. Why Git To resolve problems in lab exams (accidental deletions) Use existing Libraries with ease (Statistics and Computer) Prepare undergraduates.
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.
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.
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
CS5220 Advanced Topics in Web Programming Version Control with Git
Introduction to GitHub
Introduction to Version Control with Git
M.Sc. Juan Carlos Olivares Rojas
Information Systems and Network Engineering Laboratory II
I Don’t Git It: A beginner’s guide to git Presented by Mathew Robinson
Primož Gabrijelčič Git for Programmers Primož Gabrijelčič
11 Version control (part 2)
CReSIS Git Tutorial.
LECTURE 2: Software Configuration Management
Git Practice walkthrough.
Sign in on the attendance sheet!
File Version Control System
CS5220 Advanced Topics in Web Programming Version Control with Git
Software Engineering for Data Scientists
Version Control with Git and GitHub
Let’s start with some questions:
Version Control with Git accelerated tutorial for busy academics
SU Development Forum Introduction to Git - Save your projects!
Git Workflows.
Distributed Version Control with git
Akshay Narayan git up to speed with RCS Akshay Narayan
Anatomy of a Git Project
LECTURE 3: Software Configuration Management
The Big Picture
SIG: Open Week 1: GitHub Tim Choh.
Version control with Git Part II
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.
Git GitHub.
Introduction to The Git Version Control System
Advanced Git for Beginners
Presentation transcript:

Git branches and remotes Landon Cox February 2, 2017

Basic terminology and overview Commit Object pointing to a snapshot Named by hash and stored as a tree Commits have parents that point to the previous snapshot Branch Pointer to a commit (and its snapshot) e.g., “master” Remote Collection of branches stored on a remote server e.g., a gitlab or github project https://git-scm.com/book/en/v2/

Basic terminology and overview Commit Object pointing to a snapshot Named by hash and stored as a tree Commits have parents that point to the previous snapshot Branch Pointer to a commit (and its snapshot) e.g., “master” Remote Collection of branches stored on a remote server e.g., a gitlab or github project

What are these funny hex numbers? A commit and its tree What are these funny hex numbers? $> git add README test.rb LICENSE $> git commit -a -m “Initial commit”

Why will the commit hash change if I modify a file? A commit and its tree Why will the commit hash change if I modify a file? $> git add README test.rb LICENSE $> git commit -a -m “Initial commit”

A commit and its tree $> git add README test.rb LICENSE best $> git add README test.rb LICENSE $> git commit -a -m “Initial commit”

Commits and their parents What do I need to move from one commit to another?

Basic terminology and overview Commit Object pointing to a snapshot Named by hash and stored as a tree Commits have parents that point to the previous snapshot Branch Pointer to a commit (and its snapshot) e.g., “master” Remote Collection of branches stored on a remote server e.g., a gitlab or github project

A branch and its commit history

Two branches w/ same commits $> git branch testing

HEAD pointing to master branch $> git log --oneline --decorate f30ab (HEAD -> master, testing) add … 34ac2 Fixed bug #1328 - stack overflow … 98ca9 The initial commit of my project

HEAD pointing to testing branch $> git checkout testing

A new commit under testing $> vi test.rb $> git commit -a -m “made a change”

Checking out master $> git checkout master

A new commit under master Given the diffs I have, can I integrate my testing changes into master? $> vi test.rb $> git commit -a -m “another change”

Merging branches

Merging branches $> git branch iss53 $> git checkout iss53 $> git checkout -b iss53

Merging branches $> vi index.html $> git commit -a -m “added a new footer [issue 53]”

Merging branches $> git checkout master $> git checkout -b hotfix $> git commit -a -m “fixed broken link”

Merging branches $> git checkout master $> git merge hotfix

Merging branches $> git branch -d hotfix $> git checkout iss53 $> vi index.html $> git commit -a –m “finished footer [issue 53]”

Merging branches

Merge commit: special commit created from three-way merge Merging branches Merge commit: special commit created from three-way merge $> git checkout master $> git merge iss53

Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file $> git merge iss53 Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.

Edit files to manually resolve the conflict. Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file Edit files to manually resolve the conflict. $ git status On branch master You have unmerged paths. (fix conflicts and run "git commit") Unmerged paths: (use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")

Inside the conflicted file (index.html in example) Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file <<<<<<< HEAD:index.html <div id="footer">contact : email.support@github.com</div> ======= <div id="footer"> please contact us at support@github.com </div> >>>>>>> iss53:index.html Inside the conflicted file (index.html in example)

Content in master branch (since HEAD pointed to master during merge) Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file Content in master branch (since HEAD pointed to master during merge) <<<<<<< HEAD:index.html <div id="footer">contact : email.support@github.com</div> ======= <div id="footer"> please contact us at support@github.com </div> >>>>>>> iss53:index.html Content in iss53 branch

Content of conflicted file after manual resolution. Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file <div id="footer"> please contact us at support@github.com </div> Content of conflicted file after manual resolution. (i.e., kept the iss53 content, removed <<<, ===, and >>> lines)

Merging branches Sometimes merges fail due to conflicts Git cannot create the diffs to move one commit to another Often due to multiple changes to the line in a file Once conflict has been resolved, add and commit $> git add index.html $> git commit

Rebasing branches

Basic terminology and overview Commit Object pointing to a snapshot Named by hash and stored as a tree Commits have parents that point to the previous snapshot Branch Pointer to a commit (and its snapshot) e.g., “master” Remote Collection of branches stored on a remote server e.g., a gitlab or github project

Remote branches “origin” = default name of remote repo “master” = branch of remote repo

Equivalent commands to clone. Remote branches Equivalent commands to clone. $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git fetch origin $> git merge origin/master

“origin” is local name for this remote Remote branches “origin” is local name for this remote $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git fetch origin $> git merge origin/master

fetch retrieves data for remote merge remote/branch into local repo Remote branches fetch retrieves data for remote merge remote/branch into local repo $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git fetch origin $> git merge origin/master

Can name remote whatever you want, Remote branches Can name remote whatever you want, e.g., “jane” $> mkdir project $> cd project $> git init $> git remote add jane janedoe@git.ourcompany.com:project.git $> git fetch jane $> git merge jane/master

“git pull” is shorthand for fetch and merge Remote branches “git pull” is shorthand for fetch and merge $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git fetch origin $> git merge origin/master

“git pull” is shorthand for fetch and merge Remote branches “git pull” is shorthand for fetch and merge $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git pull origin master

Note that because pull merges, it can lead to conflicts Remote branches Note that because pull merges, it can lead to conflicts $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git pull origin master

“git remote –v” prints all the remotes you’ve linked Remote branches “git remote –v” prints all the remotes you’ve linked $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git remote –v

“git remote rm” removes a remote Remote branches “git remote rm” removes a remote $> mkdir project $> cd project $> git init $> git remote add origin janedoe@git.ourcompany.com:project.git $> git remote rm origin

How to work with your group project