Git. A Distributed Version Control System. Carlos García Campos carlosgc@gsyc.es



Similar documents
Version Control with Svn, Git and git-svn. Kate Hedstrom ARSC, UAF

Version Control with Git. Kate Hedstrom ARSC, UAF

PKI, Git and SVN. Adam Young. Presented by. Senior Software Engineer, Red Hat. License Licensed under

Annoyances with our current source control Can it get more comfortable? Git Appendix. Git vs Subversion. Andrey Kotlarski 13.XII.

Introduction to Git. Markus Kötter Notes. Leinelab Workshop July 28, 2015

Version control with GIT

Version Control with Git. Dylan Nugent

Introduction to Version Control

Git Basics. Christopher Simpkins Chris Simpkins (Georgia Tech) CS 2340 Objects and Design CS / 22

Gitflow process. Adapt Learning: Gitflow process. Document control

Git Basics. Christian Hanser. Institute for Applied Information Processing and Communications Graz University of Technology. 6.

Introduction to the Git Version Control System

Using Git for Project Management with µvision

Version Control with Git. Linux Users Group UT Arlington. Rohit Rawat

MOOSE-Based Application Development on GitLab

Version Control with. Ben Morgan

Version Control for Computational Economists: An Introduction

Version Control Systems: SVN and GIT. How do VCS support SW development teams?

Version Control. Version Control

Version control. HEAD is the name of the latest revision in the repository. It can be used in subversion rather than the latest revision number.

CPSC 491. Today: Source code control. Source Code (Version) Control. Exercise: g., no git, subversion, cvs, etc.)

Version Control with Git

Lab Exercise Part II: Git: A distributed version control system

Distributed Version Control with Mercurial and git

Version Control! Scenarios, Working with Git!

Version Control with Git

Introduc)on to Version Control with Git. Pradeep Sivakumar, PhD Sr. Computa5onal Specialist Research Compu5ng, NUIT

Version Control Systems

FEEG Applied Programming 3 - Version Control and Git II

An Introduction to Git Version Control for SAS Programmers

Two Best Practices for Scientific Computing

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer GIT

Version Uncontrolled! : How to Manage Your Version Control

How To Manage Source Code With Git

MATLAB & Git Versioning: The Very Basics

Git Internals. Source code control and beyond by Scott Chacon

Software configuration management

Introduction to Version Control with Git

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

An Introduction to Mercurial Version Control Software

Source Control Systems

Version control. with git and GitHub. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Developer Workshop Marc Dumontier McMaster/OSCAR-EMR

Version Control using Git and Github. Joseph Rivera

Pro Git. Scott Chacon *

Introduction to Subversion

Data management on HPC platforms

CS 2112 Lab: Version Control

Git Tutorial - How to Create a Full Project

Git, Quilt and Other Kernel Maintenance Tools

Source code management systems

AVOIDING THE GIT OF DESPAIR

Version Control. Luka Milovanov

Intro etckeeper bup ikiwiki git-annex vcsh mr Zsh Outro. Gitify your life. web, blog, configs, data, and backups

CSCB07 Software Design Version Control

Revision control systems (RCS) and

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

Git, GitHub & Web Hosting Workshop

Introducing Xcode Source Control

DRUPAL CONTINUOUS INTEGRATION. Part I - Introduction

Zero-Touch Drupal Deployment

CSE 374 Programming Concepts & Tools. Laura Campbell (Thanks to Hal Perkins) Winter 2014 Lecture 16 Version control and svn

CISC 275: Introduction to Software Engineering. Lab 5: Introduction to Revision Control with. Charlie Greenbacker University of Delaware Fall 2011

Using Git for Centralized and Distributed Version Control Workflows - Day 3. 1 April, 2016 Presenter: Brian Vanderwende

Software Configuration Management. Slides derived from Dr. Sara Stoecklin s notes and various web sources.

Introduction to Version Control with Git

Version Control with Mercurial and SSH

1. History 2. Structure 3. Git Comparison 4. File Storage 5. File Tracking 6. Staging 7. Queues (MQ) 8. Merge Tools 9. Interfaces

Git Branching for Continuous Delivery

Version control with Subversion

Work. MATLAB Source Control Using Git

Software Configuration Management and Continuous Integration

Version Control Tutorial using TortoiseSVN and. TortoiseGit

Advanced Computing Tools for Applied Research Chapter 4. Version control

Content. Development Tools 2(63)

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

Version Control Tools

Continuous Integration and Delivery at NSIDC

Version Control with Subversion

Derived from Chris Cannam's original at, an.

Version Control with Subversion and Xcode

using version control in system administration

CS108, Stanford Handout #33. CVS in Eclipse

Integrated version control with Fossil SCM

An Introduction to Mercurial Version Control Software

ECE 4750 Computer Architecture, Fall 2015 Tutorial 2: Git Distributed Version Control System

CSE 70: Software Development Pipeline Version Control with Subversion, Continuous Integration with Bamboo, Issue Tracking with Jira

[PRAKTISCHE ASPEKTE DER INFORMATIK WS 13/14]

VFP Version Control with Mercurial

Theme 1 Software Processes. Software Configuration Management

Mercurial. Why version control (Single users)

Transcription:

Git A Distributed Version Control System Carlos García Campos carlosgc@gsyc.es Carlos García Campos carlosgc@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - Git 8

The Git Object Model (Example) Image from Git Community Book (http://book.git-scm.com/index.html) Carlos García Campos carlosgc@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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@gsyc.es - 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 "work in progress for foo thing" changes, commit, push and whatever $ git stash apply 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@gsyc.es - 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 "work in progress for foo thing" changes, commit, push and whatever $ git stash apply 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@gsyc.es - 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 "work in progress for foo thing" changes, commit, push and whatever $ git stash apply 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@gsyc.es - 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 "work in progress for foo thing" changes, commit, push and whatever $ git stash apply 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@gsyc.es - Git 14

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@gsyc.es - Git 15

I use Git in the dark and nobody knows (git-svn) Import a svn repository $ git-svn clone <svn-uri> <modulename> Committing to the svn repository $ git-svn dcommit # From master branch Update the git repository from the remote svn $ git-svn rebase # From master branch Carlos García Campos carlosgc@gsyc.es - Git 16

Workflow (summary) $ git-svn clone <svn-uri> <modulename> $ git checkout -b super-feature commits and more commits $ git checkout master $ git-svn rebase (if there are changes we also rebase super-feature branch from master) $ git merge --squash super-feature (Do not forget to update the ChangeLog file, remember we are committing to a svn repository now) $ git commit -a $ git-svn dcommit Carlos García Campos carlosgc@gsyc.es - Git 17