Git Workflow Best Practices

Total Page:16

File Type:pdf, Size:1020Kb

Git Workflow Best Practices Git Workflow Best practices http://git-scm.com Anar Manafov, GSI Darmstadt ROOT Users Workshop 2013 History patches and tarballs BitKeeper Git Git was initially designed and developed by Linus Torvalds: “I'm an egotistical bastard, and I name all my projects after myself.” (Git - British English slang for a stupid or unpleasant person) 2 Design 3 Design Torvalds had several design criteria: 3 Design Torvalds had several design criteria: • Take CVS as an example of what not to do. 3 Design Torvalds had several design criteria: • Take CVS as an example of what not to do. • Support a distributed, BitKeeper-like workflow. 3 Design Torvalds had several design criteria: • Take CVS as an example of what not to do. • Support a distributed, BitKeeper-like workflow. • Very strong safeguards against corruption, either accidental or malicious. 3 Design Torvalds had several design criteria: • Take CVS as an example of what not to do. • Support a distributed, BitKeeper-like workflow. • Very strong safeguards against corruption, either accidental or malicious. • Very high performance. 3 Free and Open Source 4 Small and Fast For testing, large AWS instances were set up in the same availability zone. Git and SVN were installed on both machines, the Ruby repository was copied to both Git and SVN servers, and common operations were 5 performed on both. Data Assurance Every file and commit is checksummed and retrieved by its checksum when checked back out. It's impossible to get anything out of Git other than the exact bits you put in. 6 Staging Area • Staging and Unstaging Files. • Staging Patches. 7 Distributed 8 Subversion-Style Workflow 9 Integration Manager Workflow 10 Dictator and Lieutenants Workflow 11 Branching and Merging • Frictionless Context Switching. • Role-Based Codelines. • Feature Based Workflow. • Disposable Experimentation. 12 Feature release Hot-fixes master branches dev branches Tag v1.0 Time line 13 Feature release Hot-fixes master branches dev branches Tag v1.0 Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release feature for the future release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for the future release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Time line 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 Tag vX.Y 13 Feature release Hot-fixes master branches dev branches Tag Major feature v1.0 for the next release Bug-fixes for v1.1 feature for Tag the future v1.1 release Start release v2.0 Time line Only bug-fixes Tag v2.0 Tag vX.Y 13 Git Submodules Main repo. ... BuildSetup.cmake CMakeLists.txt LICENSE app\... app\Tracking app\Analysis ... Analysis repo. commit 06e0cfb51...5f3c Tracking repo. commit b2cf03b2f...3c2a 14 Git Submodules Analysis Tracking Main Main repo. ... BuildSetup.cmake CMakeLists.txt Tag LICENSE v1.0 app\... app\Tracking Tag app\Analysis v1.1 ... Analysis repo. commit 06e0cfb51...5f3c Tag v2.0 Tracking repo. Tag commit b2cf03b2f...3c2a vX.Y 14 more Git features 15 more Git features • Cut off a file or files from rep. (inc. history). 15 more Git features • Cut off a file or files from rep. (inc. history). • Merge / Divide repos while preserving history. 15 more Git features • Cut off a file or files from rep. (inc. history). • Merge / Divide repos while preserving history. • Cherry Pick. 15 more Git features • Cut off a file or files from rep. (inc. history). • Merge / Divide repos while preserving history. • Cherry Pick. • Playing with commits (changing, delete, reordering, squashing, splitting). 15 more Git features • Cut off a file or files from rep. (inc. history). • Merge / Divide repos while preserving history. • Cherry Pick. • Playing with commits (changing, delete, reordering, squashing, splitting). • You have always backups for free. 15 more Git features • Cut off a file or files from rep. (inc. history). • Merge / Divide repos while preserving history. • Cherry Pick. • Playing with commits (changing, delete, reordering, squashing, splitting). • You have always backups for free. • ... 15 Git commands 16 Git commands Got 15 minutes and want to learn Git? 16 Git commands Got 15 minutes and want to learn Git? Learn Git in your browser for free with http://try.github.com/ 16.
Recommended publications
  • Generating Commit Messages from Git Diffs
    Generating Commit Messages from Git Diffs Sven van Hal Mathieu Post Kasper Wendel Delft University of Technology Delft University of Technology Delft University of Technology [email protected] [email protected] [email protected] ABSTRACT be exploited by machine learning. The hypothesis is that methods Commit messages aid developers in their understanding of a con- based on machine learning, given enough training data, are able tinuously evolving codebase. However, developers not always doc- to extract more contextual information and latent factors about ument code changes properly. Automatically generating commit the why of a change. Furthermore, Allamanis et al. [1] state that messages would relieve this burden on developers. source code is “a form of human communication [and] has similar Recently, a number of different works have demonstrated the statistical properties to natural language corpora”. Following the feasibility of using methods from neural machine translation to success of (deep) machine learning in the field of natural language generate commit messages. This work aims to reproduce a promi- processing, neural networks seem promising for automated commit nent research paper in this field, as well as attempt to improve upon message generation as well. their results by proposing a novel preprocessing technique. Jiang et al. [12] have demonstrated that generating commit mes- A reproduction of the reference neural machine translation sages with neural networks is feasible. This work aims to reproduce model was able to achieve slightly better results on the same dataset. the results from [12] on the same and a different dataset. Addition- When applying more rigorous preprocessing, however, the per- ally, efforts are made to improve upon these results by applying a formance dropped significantly.
    [Show full text]
  • Introduction to Version Control with Git
    Warwick Research Software Engineering Introduction to Version Control with Git H. Ratcliffe and C.S. Brady Senior Research Software Engineers \The Angry Penguin", used under creative commons licence from Swantje Hess and Jannis Pohlmann. March 12, 2018 Contents 1 About these Notes1 2 Introduction to Version Control2 3 Basic Version Control with Git4 4 Releases and Versioning 11 Glossary 14 1 About these Notes These notes were written by H Ratcliffe and C S Brady, both Senior Research Software Engineers in the Scientific Computing Research Technology Platform at the University of Warwick for a series of Workshops first run in December 2017 at the University of Warwick. This document contains notes for a half-day session on version control, an essential part of the life of a software developer. This work, except where otherwise noted, is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Li- cense. To view a copy of this license, visit http://creativecommons.org/ licenses/by-nc-nd/4.0/. The notes may redistributed freely with attribution, but may not be used for commercial purposes nor altered or modified. The Angry Penguin and other reproduced material, is clearly marked in the text and is not included in this declaration. The notes were typeset in LATEXby H Ratcliffe. Errors can be reported to [email protected] 1.1 Other Useful Information Throughout these notes, we present snippets of code and pseudocode, in particular snippets of commands for shell, make, or git. These often contain parts which you should substitute with the relevant text you want to use.
    [Show full text]
  • Distributed Configuration Management: Mercurial CSCI 5828 Spring 2012 Mark Grebe Configuration Management
    Distributed Configuration Management: Mercurial CSCI 5828 Spring 2012 Mark Grebe Configuration Management Configuration Management (CM) systems are used to store code and other artifacts in Software Engineering projects. Since the early 70’s, there has been a progression of CM systems used for Software CM, starting with SCCS, and continuing through RCS, CVS, and Subversion. All of these systems used a single, centralized repository structure. Distributed Configuration Management As opposed to traditional CM systems, Distributed Configuration Management Systems are ones where there does not have to be a central repository. Each developer has a copy of the entire repository and history. A central repository may be optionally used, but it is equal to all of the other developer repositories. Advantages of Distributed Configuration Management Distributed tools are faster than centralized ones since metadata is stored locally. Can use tool to manage changes locally while not connected to the network where server resides. Scales more easily, since all of the load is not on a central server. Allows private work that is controlled, but not released to the larger community. Distributed systems are normally designed to make merges easy, since they are done more often. Mercurial Introduction Mercurial is a cross-platform, distributed configuration management application. In runs on most modern OS platforms, including Windows, Linux, Solaris, FreeBSD, and Mac OSX. Mercurial is written 95% in Python, with the remainder written in C for speed. Mercurial is available as a command line tool on all of the platforms, and with GUI support programs on many of the platforms. Mercurial is customizable with extensions, hooks, and output templates.
    [Show full text]
  • Higher Inductive Types (Hits) Are a New Type Former!
    Git as a HIT Dan Licata Wesleyan University 1 1 Darcs Git as a HIT Dan Licata Wesleyan University 1 1 HITs 2 Generator for 2 equality of equality HITs Homotopy Type Theory is an extension of Agda/Coq based on connections with homotopy theory [Hofmann&Streicher,Awodey&Warren,Voevodsky,Lumsdaine,Garner&van den Berg] 2 Generator for 2 equality of equality HITs Homotopy Type Theory is an extension of Agda/Coq based on connections with homotopy theory [Hofmann&Streicher,Awodey&Warren,Voevodsky,Lumsdaine,Garner&van den Berg] Higher inductive types (HITs) are a new type former! 2 Generator for 2 equality of equality HITs Homotopy Type Theory is an extension of Agda/Coq based on connections with homotopy theory [Hofmann&Streicher,Awodey&Warren,Voevodsky,Lumsdaine,Garner&van den Berg] Higher inductive types (HITs) are a new type former! They were originally invented[Lumsdaine,Shulman,…] to model basic spaces (circle, spheres, the torus, …) and constructions in homotopy theory 2 Generator for 2 equality of equality HITs Homotopy Type Theory is an extension of Agda/Coq based on connections with homotopy theory [Hofmann&Streicher,Awodey&Warren,Voevodsky,Lumsdaine,Garner&van den Berg] Higher inductive types (HITs) are a new type former! They were originally invented[Lumsdaine,Shulman,…] to model basic spaces (circle, spheres, the torus, …) and constructions in homotopy theory But they have many other applications, including some programming ones! 2 Generator for 2 equality of equality Patches Patch a a 2c2 diff b d = < b c c --- > d 3 3 id a a b b
    [Show full text]
  • Homework 0: Account Setup for Course and Cloud FPGA Intro Questions
    Cloud FPGA Homework 0 Fall 2019 Homework 0 Jakub Szefer 2019/10/20 Please follow the three setup sections to create BitBucket git repository, install LATEX tools or setup Overleaf account, and get access to the course's git repository. Once you have these done, answer the questions that follow. Submit your solutions as a single PDF file generated from a template; more information is at end in the Submission Instructions section. Setup BitBucket git Repository This course will use git repositories for code development. Each student should setup a free BitBucket (https://bitbucket.org) account and create a git repository for the course. Please make the repository private and give WRITE access to your instructor ([email protected]). Please send the URL address of the repository to the instructor by e-mail. Make sure there is a README:md file in the repository (access to the repository will be tested by a script that tries to download the README:md from the repository address you share). Also, if you are using a Apple computer, please add :gitignore file which contains one line: :DS Store (to prevent the hidden :DS Store files from accidentally being added to the repository). If you have problems accessing BitBucket git from the command line, please see the Appendix. Setup LATEX and Overleaf Any written work (including this homework's solutions) will be submitted as PDF files generated using LATEX [1] from provided templates. Students can setup a free Overleaf (https://www. overleaf.com) account to edit LATEX files and generate PDFs online; or students can install LATEX tools on their computer.
    [Show full text]
  • Version Control – Agile Workflow with Git/Github
    Version Control – Agile Workflow with Git/GitHub 19/20 November 2019 | Guido Trensch (JSC, SimLab Neuroscience) Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich, JSC:SimLab Neuroscience 2 Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich, JSC:SimLab Neuroscience 3 Motivation • Version control is one aspect of configuration management (CM). The main CM processes are concerned with: • System building • Preparing software for releases and keeping track of system versions. • Change management • Keeping track of requests for changes, working out the costs and impact. • Release management • Preparing software for releases and keeping track of system versions. • Version control • Keep track of different versions of software components and allow independent development. [Ian Sommerville,“Software Engineering”] Forschungszentrum Jülich, JSC:SimLab Neuroscience 4 Motivation • Keep track of different versions of software components • Identify, store, organize and control revisions and access to it • Essential for the organization of multi-developer projects is independent development • Ensure that changes made by different developers do not interfere with each other • Provide strategies to solve conflicts CONFLICT Alice Bob Forschungszentrum Jülich, JSC:SimLab Neuroscience 5 Content Motivation Version Control Systems (VCS) Understanding Git GitHub (Agile Workflow) References Forschungszentrum Jülich,
    [Show full text]
  • Scaling Git with Bitbucket Data Center
    Scaling Git with Bitbucket Data Center Considerations for large teams switching to Git Contents What is Git, why do I want it, and why is it hard to scale? 01 Scaling Git with Bitbucket Data Center 05 What about compliance? 11 Why choose Bitbucket Data Center? 13 01 What is Git, why do I want it, and why is it hard to scale? So. Your software team is expanding and taking on more high-value projects. That’s great news! The bad news, however, is that your centralized version control system isn’t really cutting it anymore. For growing IT organizations, Some of the key benefits Codebase safety moving to a distributed version control system is now of adopting Git are: Git is designed with maintaining the integrity considered an inevitable shift. This paper outlines some of managed source code as a top priority, using secure algorithms to preserve your code, change of the benefits of Git as a distributed version control system history, and traceability against both accidental and how Bitbucket Data Center can help your company scale and malicious change. Distributed development its Git-powered operations smoothly. Community Distributed development gives each developer a working copy of the full repository history, Git has become the expected version control making development faster by speeding up systems in many circles, and is very popular As software development increases in complexity, and the commit process and reducing developers’ among open source projects. This means its easy development teams become more globalized, centralized interdependence, as well as their dependence to take advantage of third party libraries and on a network connection.
    [Show full text]
  • New York Software Symposium New York Information Technology Center June 24 - 25, 2011
    New York Software Symposium New York Information Technology Center June 24 - 25, 2011 Fri, Jun. 24, 2011 Room 2 Room 3 Room 4 Room 5 Room 6 8:00 - 9:00 AM REGISTRATION/BREAKFAST/WELCOME 9:00 - 10:30 AM Slimmed Down Software: Busy Java Developer&apos;s Sonar: Code Quality Programming HTML5 Concurrency without A Lean Approach Guide to Java 7 Metrics Made Easy Tim Berglund pain in pure Java Hamlet D`Arcy Ted Neward Matthew McCullough Venkat Subramaniam 10:30 - 11:00 AM BREAK 11:00 - 12:30 PM New Ideas for Old Code Busy Java Developer&apos;s Open Source Debugging NoSQL Smackdown! Collections for Concurrency Hamlet D`Arcy Guide to Games Tools for Java Tim Berglund Venkat Subramaniam Ted Neward Matthew McCullough 12:30 - 2:30 PM LUNCH & KEYNOTE 2:30 - 4:00 PM Pragmatic Architecture Java Boilerplate Busters Cascading through Hadoop: A Getting Started with Grails Programming in Functional Style Ted Neward Hamlet D`Arcy DSL for Simpler MapReduce Tim Berglund Venkat Subramaniam Matthew McCullough 4:00 - 4:30 PM BREAK 4:30 - 6:00 PM How to Select and Architectural Kata Workshop Resource-Oriented Cassandra: Radical Scala for the Intrigued Adopt a Technology Ted Neward Architectures : REST I NoSQL Scalability Venkat Subramaniam Peter Bell Brian Sletten Tim Berglund New York Software Symposium New York Information Technology Center June 24 - 25, 2011 Sat, Jun. 25, 2011 Room 2 Room 3 Room 4 Room 5 Room 6 8:00 - 9:00 AM BREAKFAST 9:00 - 10:30 AM Cryptography on the Resource-Oriented Integrating JVM Languages Complexity Theory and Busy Java Developer&apos;s
    [Show full text]
  • Git Basics Git Expertise
    Overview Git basics Git expertise Git A GNU Alternative to Bitkeeper Mohamed Barakat University of Kaiserslautern ITWM Kaiserslautern, January 2010 Mohamed Barakat Git Overview Git basics Git expertise 1 Git basics The Git configuration file Create a Git-repository Using a Git-repository 2 Git expertise Branching Pulling Merging and Cherry-Picking Mohamed Barakat Git Overview The Git configuration file Git basics Create a Git-repository Git expertise Using a Git-repository Overview 1 Git basics The Git configuration file Create a Git-repository Using a Git-repository 2 Git expertise Branching Pulling Merging and Cherry-Picking Mohamed Barakat Git Overview The Git configuration file Git basics Create a Git-repository Git expertise Using a Git-repository Git working copy and Git-repsoitory Git is a distributed SCM Git is a distributed Source Code Management system (SCM), i.e. each Git working copy sits on top of its own local Git repository located in a single top-level subdirectory .git. SVN is in contrast to Git a centralized SCM system, i.e. the SVN-repository is on exactly one server. Git allows you to commit, checkout, reset, etc. without contacting a server! Mohamed Barakat Git Overview The Git configuration file Git basics Create a Git-repository Git expertise Using a Git-repository The configuration file ˜/.gitconfig Create a Git configuration file vi ˜/.gitconfig [svn] authorsfile = .git/info/svn-authors [color] diff = auto status = auto branch = auto [user] name = Firstname Lastname email = [email protected] Mohamed Barakat Git Overview The Git configuration file Git basics Create a Git-repository Git expertise Using a Git-repository Create a Git-repository (quick version) init, add, commit Create a Git-repository in the directory XY: 1 cd XY 2 git init 3 git add .
    [Show full text]
  • INF5750/9750 - Lecture 1 (Part III) Problem Area
    Revision control INF5750/9750 - Lecture 1 (Part III) Problem area ● Software projects with multiple developers need to coordinate and synchronize the source code Approaches to version control ● Work on same computer and take turns coding ○ Nah... ● Send files by e-mail or put them online ○ Lots of manual work ● Put files on a shared disk ○ Files get overwritten or deleted and work is lost, lots of direct coordination ● In short: Error prone and inefficient The preferred solution ● Use a revision control system. RCS - software that allows for multiple developers to work on the same codebase in a coordinated fashion ● History of Revision Control Systems: ○ File versioning tools, e.g. SCCS, RCS ○ Central Style - tree versioning tools. e.g. CVS ○ Central Style 2 - tree versioning tools e.g. SVN ○ Distributed style - tree versioning tools e.g. Bazaar ● Modern DVCS include Git, Mercurial, Bazaar Which system in this course? ● In this course we will be using GIT as the version control system ● We will use the UIO git system, but you can also make git accounts on github.com or bitbucket for your own projects ● DHIS2 uses a different system: Launchpad/Bazaar How it works Working tree: Local copy of the source code Repository: residing on the Central storage of developer’s the source code at computer (a client) a server synchronize synchronize Commit Commit locally Centralized De-centralized The repository Central ● Remembers every change ever written to it (called commits) ● You can have a central or local repository. ○ Central = big server in
    [Show full text]
  • Hg Mercurial Cheat Sheet Serge Y
    Hg Mercurial Cheat Sheet Serge Y. Stroobandt Copyright 2013–2020, licensed under Creative Commons BY-NC-SA #This page is work in progress! Much of the explanatory text still needs to be written. Nonetheless, the basic outline of this page may already be useful and this is why I am sharing it. In the mean time, please, bare with me and check back for updates. Distributed revision control Why I went with Mercurial • Python, Mozilla, Java, Vim • Mercurial has been better supported under Windows. • Mercurial also offers named branches Emil Sit: • August 2008: Mercurial offers a comfortable command-line experience, learning Git can be a bit daunting • December 2011: Git has three “philosophical” distinctions in its favour, as well as more attention to detail Lowest common denominator It is more important that people start using dis- tributed revision control instead of nothing at all. The Pro Git book is available online. Collaboration styles • Mercurial working practices • Collaborating with other people Use SSH shorthand 1 Installation $ sudo apt-get update $ sudo apt-get install mercurial mercurial-git meld Configuration Local system-wide configuration $ nano .bashrc export NAME="John Doe" export EMAIL="[email protected]" $ source .bashrc ~/.hgrc on a client user@client $ nano ~/.hgrc [ui] username = user@client editor = nano merge = meld ssh = ssh -C [extensions] convert = graphlog = mq = progress = strip = 2 ~/.hgrc on the server user@server $ nano ~/.hgrc [ui] username = user@server editor = nano merge = meld ssh = ssh -C [extensions] convert = graphlog = mq = progress = strip = [hooks] changegroup = hg update >&2 Initiating One starts with initiate a new repository.
    [Show full text]
  • Collaboration Tools in Software Engineering Stepan Bolotnikov Me
    Collaboration Tools in Software Engineering Stepan Bolotnikov Me ● Stepan Bolotnikov ● Software Engineer at Guardtime ● MSc in Software Engineering from UT, 2018 ● [email protected] You Mostly BSc students in Computer Science ● Software developers / QA engineers ● CS researchers ● Project managers / team leads In any case connected to software projects, sharing knowledge and resources Course ● History and working principles of version control systems (VCS) ● Git distributed VCS ● Issue tracking ● Theoretical knowledge + practical hands-on exercises ● 8 sessions ● Every 2nd Friday ● Lecture + practice ● Non-differentiated (pass/fail) Schedule ● 22. Feb - Introduction, history of VCS ● 08. Mar - Introduction to Git, setting up the first repository, basic Git usage ● 22. Mar - Common Git commands ● 05. Apr - Branching in Git, common branching models ● 19. Apr - Troubleshooting common Git issues ● 03. May - Github; Issue tracking ● 17. May - Advanced Git usage; git hooks and CI ● 31. May - Guest lecture, preparation for exam ● 07. June - Exam 1 ● 14. June - Exam 2 Sessions ● 4h ● Lecture part ● Practical part Final exam ● 7th or 17th June ● Individual practical tasks ● “Poor”, “Satisfactory” or “Good” ● “Satisfactory” and “Good” - passing In order to pass the course ● Active participation in at least 6 out of 8 sessions ○ Complete the practical tasks ● “Satisfactory” or “Good” on the final exam Communication Course website http://courses.cs.ut.ee/2019/cse Course Slack Click Lecture 1: Introduction to course, History of Version
    [Show full text]