ebook img

Git Version Control Cookbook: Leverage version control to transform your development workflow and boost productivity PDF

350 Pages·2018·12.819 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Git Version Control Cookbook: Leverage version control to transform your development workflow and boost productivity

Git Version Control Cookbook Second Edition Leverage version control to transform your development workflow and boost productivity Kenneth Geisshirt Emanuele Zattin Aske Olsson Rasmus Voss BIRMINGHAM - MUMBAI Git Version Control Cookbook Second Edition Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Aaron Lazar Acquisition Editor: Shriram Shekhar Content Development Editor: Pooja Parvatkar Technical Editor: Subhalaxmi Nadar Copy Editor: Safis Editing Project Coordinator: Ulhas Kambali Proofreader: Safis Editing Indexer: Rekha Nair Graphics: Tania Dutta Production Coordinator: Deepika Naik First published: July 2014 Second edition: July 2018 Production reference: 1240718 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78913-754-5 www.packtpub.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the authors Kenneth Geisshirt is a chemist, by education, and a strong free-software advocate. He spent his Christmas holidays in 1992 installing SLS Linux, and GNU/Linux has been his favorite operating system ever since. Currently, he does consultancy work in fields such as scientific computing and Linux clusters. He lives in Copenhagen, Denmark, with his partner and their two children. As a programmer, I have used many versioning systems. I began with CVS, followed by Subversion and Telelogic Synergy. During the last 7 years, Git has become an integral part of my life. Over the years, many people have been kind with their support, especially my wife and children, who always let me be the geek I am. Emanuele Zattin is the Continuous Integration Specialist at Realm Inc. with experience in software development and design. He is respected for his work in designing and developing a CM Synergy to Git history conversion tool and rolling out Git-Gerrit-Jenkins in several Nokia divisions. I would like to thank my coauthor, Kenneth, for convincing me to embark on this adventure; my wife, Cecilie; and our children, Sebastian and Mia, for their patience and support. I would also like to thank Aske and Rasmus, the authors of the first edition of this book, whose work has proven to be an incredibly strong base for the current edition. Aske Olsson has more than 14 years of experience in the software industry. As an electrical engineer, he has been using every tool available for development, from a soldering iron over Assembly, C, Java Groovy, Python and various DSLs for programming to different SCMs and build-, CI- and issue-tracking systems. He has worked for Nokia for 6 years and, currently, works at Keylane. Aske has experience with Git; he has been teaching Git in regular training sessions, from basic Git to advanced usage. Rasmus Voss has been working with continuous integration, continuous delivery, automatic testing, and DevOps, in various industries. He has always strived to ensure that where developers, testers, project leaders, and managers can work with the system instead of against the system. Typically, the processes and solutions he develops are clear, precise, and well documented, with relevant feedback to all parts of the software development process. About the reviewer Chen Mulong has been working on mobile development for over 10 years. He has coded for all different kinds of mobile devices, from the ancient feature phone platform, which is made of plain C, to the modern smart device platform, Android. Open source is his first choice for solving daily problems. He has experienced the chaos of being part of a team of 100+ developers and the peace brought about by excellent SCM tools. He loves to tell others how good Git is at making every developer's life easier. He now works as a freelancer in Beijing, China. Thanks to the writers for giving me the chance to review this book and learn so many things I hadn't tried before with Git. The book not only helped me to refresh my knowledge of Git basic, but also inspired me to get more work done by combining various simple Git commands into an automatic script. I enjoyed reading the tricks and examples contained in the book even as entertainment. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: Navigating Git 6 Introduction 6 Git's objects 8 Getting ready 9 How to do it... 9 The commit object 9 The tree object 10 The blob object 11 The branch object 11 The tag object 12 How it works... 12 There's more... 13 The three stages 13 Getting ready 13 How to do it... 14 How it works... 16 See also 17 Viewing the DAG 17 Getting ready 18 How to do it... 19 How it works... 21 Extracting fixed issues 21 Getting ready 21 How to do it... 22 How it works... 24 There's more... 24 Getting a list of the changed files 24 Getting ready 24 How to do it... 25 How it works... 25 There's more... 25 See also 26 Viewing the history with gitk 26 Getting ready 26 How to do it... 27 How it works... 27 There's more... 28 Finding commits in the history 28 Table of Contents Getting ready 28 How to do it... 28 How it works... 29 There's more... 29 Searching through the history code 30 Getting ready 30 How to do it... 31 How it works... 31 There's more... 31 Chapter 2: Configuration 33 Introduction 33 Configuration targets 33 Getting ready 34 How to do it... 34 How it works... 36 There's more... 36 Querying the existing configuration 36 Getting ready 36 How to do it... 37 How it works... 37 There's more... 38 Templates 39 Getting ready 39 How to do it... 39 How it works... 40 A .git directory template 40 Getting ready 41 How to do it... 42 How it works... 43 See also 43 A few configuration examples 43 Getting ready 44 How to do it... 44 Rebase and merge setup 44 Expiry of objects 45 Autocorrect 46 How it works... 47 There's more... 47 Git aliases 47 Getting ready 47 How to do it... 48 How it works... 51 There's more... 51 The refspec exemplified 51 Getting ready 51 [ ii ] Table of Contents How to do it... 52 How it works... 54 Chapter 3: Branching, Merging, and Options 55 Introduction 55 Managing your local branches 56 Getting ready 56 How to do it... 56 How it works... 57 There's more... 58 Branches with remotes 59 Getting ready 59 How to do it... 61 There's more... 62 Forcing a merge commit 63 Getting ready 64 How to do it... 64 There's more... 66 Using git reuse recorded resolution (rerere) to merge Git conflicts 67 How to do it... 68 There's more... 71 Compute the difference between branches 73 Getting ready 73 How to do it... 73 Orphan branches 75 Getting ready 75 How to do it... 76 There's more... 78 Chapter 4: Rebasing Regularly and Interactively, and Other Use Cases 79 Introduction 79 Rebasing commits to another branch 80 Getting ready 80 How to do it... 80 How it works... 81 Continuing a rebase with merge conflicts 81 How to do it... 81 How it works... 83 There's more... 83 Rebasing selected commits interactively 84 Getting ready 84 How to do it... 84 There's more... 86 Squashing commits using an interactive rebase 87 Getting ready 87 [ iii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.