Git. A Distributed Version Control System. Carlos García Campos

Similar documents
a handful of Git workflows for the agilist steven harman twitter: stevenharman

Git Workflows. Sylvain Bouveret, Grégory Mounié, Matthieu Moy

Introduction to Version Control

Git. all meaningful operations can be expressed in terms of the rebase command. -Linus Torvalds, 2015

Version Control: Gitting Started

GUIDE TO MAKE A REAL CONTRIBUTION TO AN OPEN SOURCE PROJECT 1. 1

Git for Subversion users

Version Control with Git

Version Control System - Git. zswu

Git. Ľubomír Prda. IT4Innovations.

Source Code Management wih git

Topics covered. Introduction to Git Git workflows Git key concepts Hands on session Branching models. Git 2

Introduction to GIT. Jordi Blasco 14 Oct 2011

About SJTUG. SJTU *nix User Group SJTU Joyful Techie User Group

Introduction to GIT. The distributed SCM

Versioning with git. Moritz August Git/Bash/Python-Course for MPE. Moritz August Versioning with Git

Git. Presenter: Haotao (Eric) Lai Contact:

GIT Princípy tvorby softvéru, FMFI UK Jana Kostičová,

Gitting things done. Hands-on introduction to git niceties. Jan Urbański Ducksboard

Revision Control. An Introduction Using Git 1/15

Agenda. Several projects are using GIT Developer(s) Junio Hamano, Linus Torvalds. Qt Stable release (January 31, 2011)

Git, the magical version control

Introduction to distributed version control with git

CESSDA Expert Seminar 13 & 14 September 2016 Prague, Czech Republic

INET

Git. (Why not CVS?... because Git.) Karel Zak Florian Festi Bart Trojanowski December 20, 2007

Distributed Version Control (with Git)

VCS VERSION CONTROL SYSTEMS

August 22, New Views on your History with git replace. Christian Couder

Common Git Commands. Git Crash Course. Teon Banek April 7, Teon Banek (TakeLab) Common Git Commands TakeLab 1 / 18

Advanced Git. Luc Sarzyniec. Xilopix, February / 88

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Computer Science Design I Version Control with Git

Git. A fast distributed revision control system. Nils Moschüring PhD Student (LMU)

Git version control with Eclipse (EGit) Tutorial

GIT for companies Mark Struberg, INSO TU Vienna

[Software Development] Development Tools. Davide Balzarotti. Eurecom Sophia Antipolis, France

git Version: 2.0b Merge combines trees, and checks out the result Pull does a fetch, then a merge If you only can remember one command:

Beyond git add/commit/push

Creating a Patch. Created by Carl Heymann on 2010 Sep 14 1

Submitting your Work using GIT

Outline The three W s Overview of gits structure Using git Final stuff. Git. A fast distributed revision control system

Best Practices. Joaquim Rocha IT-DSS-TD

Git tutorial. Katie Osterried C2SM. October 22, 2015

Version Control with Git

Version control with Git.

A BASIC UNDERSTANDING OF VERSION CONTROL

What is git? Distributed Version Control System (VCS); Created by Linus Torvalds, to help with Linux development;

git the SCM system Jan-Simon Möller training.linuxfoundation.org

Git Like You Mean it. Alan Ott SCaLE 16x March 8-11, 2018

Index. Alias syntax, 31 Author and commit attributes, 334

Outline. Introduction to Version Control Systems Origins of Git Git terminology & concepts Basic Git commands Branches in Git Git over the network

Outline. Version Control System (VCS) basics Git terminology & concepts Basic Git commands Branches in Git Git over the network (time permitting)

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

Git for Version Control

Push up your code next generation version control with (E)Git

Version Control Systems (VCS)

! #Running this command from the top directory of your project will add all your changes."! $ git add."

Git Tutorial. André Sailer. ILD Technical Meeting April 24, 2017 CERN-EP-LCD. ILD Technical Meeting, Apr 24, 2017 A. Sailer: Git Tutorial 1/36

February 2 nd Jean Parpaillon

CSE 391 Lecture 9. Version control with Git

Version Control. Version Control

Git Resolve Conflict Using Mine Command Line

Assumptions. GIT Commands. OS Commands

GETTING TO KNOW GIT: PART II JUSTIN ELLIOTT PENN STATE UNIVERSITY

Θερινό Σχολείο, Ιουλίου git. Αχιλλέας Πιπινέλης. Μονάδα Αριστείας ΕΛ/ΛΑΚ ΤΕΙ Αθήνας

E, F. deleteall command, 352 directory structure, 350 export_data method, 353 inline_data method, 353 print_export method, 351 target directory, 351

RSARTE Git Integration

Advanced Operating Systems Control Versioning with GIT. Giuseppe Massari

How to be a git. Dominic Mitchell

Introduction to Git and Github

GETTING STARTED WITH. Michael Lessard Senior Solutions Architect June 2017

Fundamentals of Git 1

An introduction to git

Introduction, Instructions and Conventions

Revision control Advanced git

Git Introduction CS 400. February 11, 2018

Algorithm Engineering

Source Code Management wih git

Revision Control and GIT

GIT. CS 490MT/5555, Spring 2017, Yongjie Zheng

Tools for software development:

Git. Charles J. Geyer School of Statistics University of Minnesota. Stat 8054 Lecture Notes

DEAD-SIMPLE VERSION CONTROL FOR YOUR TEAM GIT WITH MATTHEW REIDSMA GRAND VALLEY STATE UNIVERSITY

CS 390 Software Engineering Lecture 5 More Git

Understanding. Steve

Working in Teams CS 520 Theory and Practice of Software Engineering Fall 2018

TDDC88 Lab 4 Software Configuration Management

Version Control with GIT

Contribute To Linux Mainline

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 17, 2018

Basics of Git GitHub

Getting the Source Code

MOOSE-Based Application Development on GitLab

Git for Newbies. ComMouse Dongyue Studio

AIS Grid School 2015

RSARTE Git Integration

Using Git to Manage Source RTL

Outline. Introduction to Version Control Systems Origins of Git Git terminology & concepts Basic Git commands Branches in Git Git over the network

GIT CHEAT SHEET. CONFIG --global => write to ~/.gitconfig, otherwise to.git/config. git config [--global] -l git config [--global] -e

Transcription:

Git A Distributed Version Control System Carlos García Campos carlosgc@gnome.org Carlos García Campos carlosgc@gnome.org - Git 1

A couple of Quotes For the first 10 years of kernel maintenance, we literally used tarballs and patches, which is a much superior source code management system than CVS is[...] Linus Torvalds When I say I hate CVS with a passion, I have to also say that if there any SVN users in the audience, you might want to leave. Because my hatred of CVS has meant that I see Subversion as being the most pointless project ever started, because the whole slogan for the Subversion for a while was CVS done right or something like that. And if you start with that kind of slogan, there is nowhere you can go. It s like, there is no way to do CVS right. Linus Torvalds Carlos García Campos carlosgc@gnome.org - Git 2

First of all Getting started Telling git who you are [user] name = Your Name email = your@mail.ext Global: ~/.gitconfig Repository specific: repodir/.git/config Extensible config file git-config command Carlos García Campos carlosgc@gnome.org - Git 3

Basic operations Creating/Initializing a new repository $ mkdir project $ cd project $ git init Committing $ git add file $ git commit Differences git diff: differences between the work tree and the index git diff --cached: differences between HEAD and the index Special shortcut for committing $ git commit -a Status $ git status NOTE: the index is a snapshot of the working tree that represents the content that will be affected by a commit Carlos García Campos carlosgc@gnome.org - Git 4

Fixing mistakes Resetting by changing the history $ git reset --hard <commit> Reverting with a new commit $ git revert <commit> Getting an old version of a file $ git checkout <commit> path/to/file Carlos García Campos carlosgc@gnome.org - Git 5

git log commit ce6ddeac2200225b173c52e2509ffcc01b2b4a1d Author: Carlos Garcia Campos <carlosgc@gnome.org> Date: Mon Nov 19 16:14:01 2007 +0100 Initial commit Commit: commit id (sha1) Author: commit author (not the committer) Date: commit date Commit message: (a single line briefly describing the change and, optionally, a blank line followed by one or more lines with a detailed description) ChangeLog file is no longer needed. Carlos García Campos carlosgc@gnome.org - Git 6

Customizing the log command output Change stats: --stat Diff of the changes (patch): -p With information about the altered paths: --name-status Wit full information about both the Author and Committer: --pretty=fuller Limiting the amount of commits shown : -n<n_commits> Useful shortcut: git show Carlos García Campos carlosgc@gnome.org - Git 7

Git internals The whole history of the repository is stored by Git in files referenced by its contents (SHA1) rather than a file name. Such files are the objects that form the Git Object Model. Every object consists of a type, a size and its contents. Four types of objects: blob is just a file tree is a container of pointers to blobs and other tree objects commit is a link to a physical state of a tree with a description of how we got there and why tag is used to mark commit objects with a label Carlos García Campos carlosgc@gnome.org - Git 8

The Git Object Model (Example) Image from Git Community Book (http://book.git-scm.com/index.html) Carlos García Campos carlosgc@gnome.org - Git 9

Working with branches Branches are quite cheap (fast and clean process) Creating a new branch $ git branch <branch> [<start-point>] Listing available branches $ git branch Changing the current branch $ git checkout Creating a branch and changing to it in a single operation $ git checkout -b <branch> [<start-point>] Merging branches $ git merge <branch> Updating the current branch from another $ git rebase <branch> Carlos García Campos carlosgc@gnome.org - Git 10

Pulling Getting started Cloning a repository (clone!= checkout) $ git clone <uri> Getting updates $ git fetch <uri> $ git merge origin/master Useful shortcut (commonly used) $ git pull Updating a remote repository $ git push Carlos García Campos carlosgc@gnome.org - Git 11

Workflow (Summary) $ git clone <uri> $ cd project $ git checkout -b new-feature (some changes, git add, etc.) $ git commit -a (more changes) $ git commit -a (last changes, my new feature is now ready) $ git commit -a $ git checkout master $ git pull $ git checkout new-feature $ git rebase master $ git checkout master $ git merge new-feature $ git push origin master Carlos García Campos carlosgc@gnome.org - Git 12

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Big advantages for the daily work Offline work Working on more than one feature at the same time Micro-commits Easy sharing of code Author!= Committer Better history Interactivity with other systems (git-svn, git-cvs) Performance!!! Carlos García Campos carlosgc@gnome.org - Git 13

Some tips and tricks Cherry-picking $ git cherry-pick <commit> Move this away for a while, I need to fix something first $ git stash save "work in progress for foo thing" changes, commit, push and whatever $ git stash apply Add chunks of files to the index $ git add file1 file2... filen --patch Carlos García Campos carlosgc@gnome.org - Git 14

Some tips and tricks Cherry-picking $ git cherry-pick <commit> Move this away for a while, I need to fix something first $ git stash save "work in progress for foo thing" changes, commit, push and whatever $ git stash apply Add chunks of files to the index $ git add file1 file2... filen --patch Carlos García Campos carlosgc@gnome.org - Git 14

Some tips and tricks Cherry-picking $ git cherry-pick <commit> Move this away for a while, I need to fix something first $ git stash save "work in progress for foo thing" changes, commit, push and whatever $ git stash apply Add chunks of files to the index $ git add file1 file2... filen --patch Carlos García Campos carlosgc@gnome.org - Git 14

Some tips and tricks Append changes to last commit $ git commit --amend Merge this, but please, do not change the history because I have some embarrassing private commits $ git merge --squash <branch> $ git commit -a $ git push Looking for a regression $ git bisect start $ git bisect good <commit-id> $ git bisect bad <commit-id> $ git bisect [good bad] (repeat until you find the guilty commit telling git if current version is good or bad) $ git bisect reset Carlos García Campos carlosgc@gnome.org - Git 15

Some tips and tricks Append changes to last commit $ git commit --amend Merge this, but please, do not change the history because I have some embarrassing private commits $ git merge --squash <branch> $ git commit -a $ git push Looking for a regression $ git bisect start $ git bisect good <commit-id> $ git bisect bad <commit-id> $ git bisect [good bad] (repeat until you find the guilty commit telling git if current version is good or bad) $ git bisect reset Carlos García Campos carlosgc@gnome.org - Git 15

Some tips and tricks Append changes to last commit $ git commit --amend Merge this, but please, do not change the history because I have some embarrassing private commits $ git merge --squash <branch> $ git commit -a $ git push Looking for a regression $ git bisect start $ git bisect good <commit-id> $ git bisect bad <commit-id> $ git bisect [good bad] (repeat until you find the guilty commit telling git if current version is good or bad) $ git bisect reset Carlos García Campos carlosgc@gnome.org - Git 15

Patches Getting started Creating series of patches $ git format-patch <commit-from>..<commit-to> Appliying series of patches $ cat patch1 patch2.. patchn > patches.mbox $ git am patches.mbox Carlos García Campos carlosgc@gnome.org - Git 16