Git Essentials - Ferdinando Santacroce - E-Book

Git Essentials E-Book

Ferdinando Santacroce

0,0
20,39 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

If you are a software developer with little or no experience of versioning systems, or are familiar with other centralized versioning systems, then this book is for you. If you have some experience working with command lines or using Linux admin or just using Unix and want to know more about Git, then this book is ideal for you.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 163

Veröffentlichungsjahr: 2015

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Git Essentials
Credits
Foreword
Foreword
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Getting Started with Git
Installing Git
Running our first Git command
Setting up a new repository
Adding a file
Commit the added file
Modify a committed file
Summary
2. Git Fundamentals – Working Locally
Repository structure and file status life cycle
The working directory
File statuses
The staging area
Unstaging a file
The time metaphor
The past
The present
The future
Working with repositories
Unstaging a file
Viewing the history
Anatomy of a commit
The commit snapshot
The commit hash
Author, e-mail, and date
Commit messages
Committing a bunch of files
Ignoring some files and folders by default
Highlighting an important commit – Git tags
Taking another way – Git branching
Anatomy of branches
Looking at the current branches
Creating a new branch
Switching from branch to branch
Understanding what happens under the hood
A bird's eye view to branches
Typing is boring – Git aliases
Merging branches
Merge is not the end of the branch
Exercises
Exercise 2.1
What you will learn
Scenario
Results
Exercise 2.2
What you will learn
Scenario
Results
Deal with branches' modifications
Diffing branches
Using a visual diff tool
Resolving merge conflicts
Edit collisions
Resolving a removed file conflict
Keeping the edited file
Resolving conflicts by removing the file
Stashing
Summary
3. Git Fundamentals – Working Remotely
Working with remotes
Setting up a new GitHub account
Cloning a repository
Uploading modifications to remotes
What do I send to the remote when I push?
Pushing a new branch to the remote
The origin
Tracking branches
Downloading remote changes
Checking for modifications and downloading them
Applying downloaded changes
Going backward: publish a local repository to GitHub
Adding a remote to a local repository
Pushing a local branch to a remote repository
Social coding – collaborate using GitHub
Forking a repository
Submitting pull requests
Creating a pull request
Summary
4. Git Fundamentals – Niche Concepts, Configurations, and Commands
Dissecting the Git configuration
Configuration architecture
Configuration levels
System level
Global level
Repository level
Listing configurations
Editing configuration files manually
Setting up other environment configurations
Basic configurations
Typos autocorrection
Push default
Defining the default editor
Other configurations
Git aliases
Shortcuts to common commands
Creating commands
git unstage
git undo
git last
git difflast
Advanced aliases with external commands
Removing an alias
Aliasing the git command itself
Git references
Symbolic references
Ancestry references
The first parent
The second parent
World-wide techniques
Changing the last commit message
Tracing changes in a file
Cherry picking
Tricks
Bare repositories
Converting a regular repository to a bare one
Backup repositories
Archiving the repository
Bundling the repository
Summary
5. Obtaining the Most – Good Commits and Workflows
The art of committing
Building the right commit
Make only one change per commit
Split up features and tasks
Write commit messages before starting to code
Include the whole change in one commit
Describe the change, not what you have done
Don't be afraid to commit
Isolate meaningless commits
The perfect commit message
Writing a meaningful subject
Adding bulleted details lines, when needed
Tie other useful information
Special messages for releases
Conclusions
Adopting a workflow – a wise act
Centralized workflows
How they work
Feature branch workflow
GitFlow
The master branch
Hotfixes branches
The develop branch
The release branch
The feature branches
Conclusion
The GitHub flow
Anything in the master branch is deployable
Creating descriptive branches off of the master
Pushing to named branches constantly
Opening a pull request at any time
Merging only after a pull request review
Deploying immediately after review
Conclusions
Other workflows
The Linux kernel workflow
Summary
6. Migrating to Git
Before starting
Prerequisites
Working on a Subversion repository using Git
Creating a local Subversion repository
Checking out the Subversion repository with svn client
Cloning a Subversion repository from Git
Setting up a local Subversion server
Adding a tag and a branch
Committing a file to Subversion using Git as a client
Using Git with a Subversion repository
Migrating a Subversion repository
Retrieving the list of Subversion users
Cloning the Subversion repository
Preserving the ignored file list
Pushing to a local bare Git repository
Arranging branches and tags
Renaming the trunk branch to master
Converting Subversion tags to Git tags
Pushing the local repository to a remote
Comparing Git and Subversion commands
Summary
7. Git Resources
Git GUI clients
Windows
Git GUI
TortoiseGit
GitHub for Windows
Atlassian SourceTree
Cmder
Mac OS X
Linux
Building up a personal Git server with web interface
The SCM Manager
Learning Git in a visual manner
Git on the Internet
Git community on Google+
GitMinutes and Thomas Ferris Nicolaisen's blog
Ferdinando Santacroce's blog
Summary
Index

Git Essentials

Git Essentials

Copyright © 2015 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 author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be 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.

First published: April 2015

Production reference: 1240415

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78528-790-9

www.packtpub.com

Credits

Author

Ferdinando Santacroce

Reviewers

Fabrizio Donina

Giovanni Giorgi

Giovanni Toraldo

Commissioning Editor

Edward Gordon

Acquisition Editor

Meeta Rajani

Content Development Editor

Samantha Gonsalves

Technical Editor

Siddhesh Ghadi

Copy Editors

Hiral Bhat

Karuna Narayanan

Alpha Singh

Project Coordinator

Kinjal Bari

Proofreaders

Simran Bhogal

Safis Editing

Paul Hindle

Bernadette Watkins

Indexer

Tejal Daruwale Soni

Graphics

Jason Monteiro

Abhinash Sahu

Production Coordinator

Nilesh R. Mohite

Cover Work

Nilesh R. Mohite

Foreword

Occasionally, in the IT industry, some inventions are made whose value is far beyond their merely technical merit. Git is one of them.

Git is immensely faster and more convenient than SVN, CVS, and TFS. It is fast becoming the defacto standard mainly because there are no tools as powerful and versatile as it is; it is a wonderful masterpiece of code. Behind the success of Git lies much more: it is a revolutionary approach to writing code. Git houses an inherently collaborative component in its DNA. It is no coincidence then that the GitHub's tagline is Social Coding.

If Linus Torvalds goes down in history, it will perhaps be not only for Linux and his genius in writing C, but above all, for the social impact that Git has had on the IT community. Just like the invention of the Web and HTTP have enabled humanity to build a network of communication and collaboration previously unthinkable, Git is the very tool that enables us to transform code development into a social activity. As a matter of fact, Git has started a new era in IT.

Git is also a very well documented tool. If you want to learn the syntax of its 155 commands, you don't need this book; the man pages, which are available for free on the web, are certainly more exhaustive.

However, the heart of Git does not lie in the list of its command options. Just like reading the syntax of the class and interface keywords will hardly make you grasp the deeper meaning of object-oriented programming, in the same way, the essence of Git won't emerge easily from its man pages.

The hardest part of Git is the paradigm shift that it requires. Honestly, very few books that I've read are able to explain Git and the universe that revolves around it, in a simpler way than the one you're holding in your hands.

This book covers not only all the main topics you can find on the man pages with simplicity and synthesis (such as the commit, stash, rebase, and management of remote), but also has the merit of being one of the few books to give you a 360-degree overview of the ecosystem that every pragmatic programmer should master. It explains how to set up a local server, teaches you the theory and practice behind GitHub and pull requests in a simple and practical way, and even contains a step-by-step guide to migrate from SVN to Git.

Git Essentials has another merit: it is built like a huge tutorial, and is a step-by-step journey through the Git universe. It's not an academic paper; on the contrary, it's full of concrete examples, is written by a programmer, and targeted at other programmers.

It is a book that values code much more than words.

Arialdo Martini

Solutions Architect at Aduno Gruppe

Foreword

At the time of writing this (April 2015), Git has just crossed the historical 10th anniversary since its inception. It is crazy for me to think it's already been 10 years.

Owing not in a small part to the innovative concepts that Git and some earlier DVCS solutions brought about, a huge chunk of the modern software development world has been turned upside down due to it. Teams that have adopted it have been greatly empowered on many fronts.

You can branch off and start working on some experimental features without bothering your colleagues. You can also keep your stable branches stable and only merge completed features. Git will also allow you to explore an entire project while on a plane without sending a single network request.

I went back and looked at my first repository and it appears I started using Git professionally in 2008. Thinking about it, I remember the initial struggle I had with some of the core concepts. Git is not particularly easy to pick up even though its user interface has improved consistently over time.

However, after so many years, we enthusiasts and early adopters have been fooled by our own reality tunnel. It's easy to fall into the perception that nowadays the entire world is already using Git and the transition has been completed. I know for a fact though, that I am mistaken!

During the course of my journey through Europe over the last two years, I have seen teams at all stages of Git adoption. I've noticed, for example, that Nordic countries, such as Sweden and Norway, have been working with Git for several years already, while in other countries, companies have only recently decided to make the transition. It's funny that just a few weeks ago somebody told me that they won't be transitioning to Git any time soon. The reason for this? They spent years migrating from CVS to SVN!

In addition to all that I've said, there is still a pressing need to educate teams all around the world about the usefulness of Git. So, I welcome Ferdinando's work with open arms and his efforts in developing a solid guide for people who want to add Git to their toolkit.

What will you gain from a good understanding of Git? It will forever change the way you write software. You'll be able to save your changes as many times as you want in an unpolished, raw form. You'll also be able to always go back and polish up everything before sharing your work with a rebase.

You will be able to work in isolation on a feature or bug fix without disturbing your teammates or lowering the quality of the master stable branch (refer to Chapter 2, Git Fundamentals – Working Locally, for this).

Finally, I can't emphasize enough how Git—and the concepts that are built on it, such as the idea of pull requests—have changed the way professional teams interact, thereby embedding a code review practice into the very texture of the software development process (refer to Chapter 5, Obtaining the Most – Good Commits and Workflows).

It's a great time to be adopting Git and reaping the benefits of this solid and efficient tool whether you are a hobbyist or a professional developer. Good luck!

Nicola Paolucci

Developer Advocate at Atlassian

Foreword

Having first used CVS as a source version control more than a decade ago, I remember how easy it was to make the transition to using Subversion, which I thought was all I needed in a source version control tool. Then came Git, Bazaar, and Mercurial, the new kids on the block. I looked at them briefly, but initially, I couldn't see what advantage they could really have for me as a programmer over Subversion, as I was working mostly on my own projects. However, it became more and more evident that to facilitate collaboration, I would have to become much more familiar with these new tools. Very soon it seemed, Git became the first choice and I started using it in earnest. I remember feeling that the tutorials I read seemed needlessly complicated, spending too much time on what I felt were unnecessary details. When I read the first draft of Git Essentials, my first thought was, "This is the book I wish I had when I first learned about Git."

Instead of jumping right away into detailed descriptions of the intricacies of dealing with multiple copies of some software shared by multiple programmers—one of the strengths of distributed source version control software such as Git—Ferdinando Santacroce, the author of Git Essentials, took a different approach, focusing on you first as a potentially lone programmer wishing to use Git.

After going through the basics of installing Git in the first chapter, Ferdinando devotes the following chapter to using it locally, that is, without working with an external repository. This allows you to focus on the basics of Git without the unnecessary complication of dealing with the added concept of an external repository. This is not the way I have seen Git being introduced usually—yet, it is definitely the right way. From this point on, there is a logical progression with important concepts highlighted in a progressive manner. Ferdinando postpones the added complication of working with a remote repository until Chapter 3, Git Fundamentals – Working Remotely, using GitHub as an example. Since GitHub has become the most widely used Git repository in the world, this choice is very logical. Yet, the concepts explained in this chapter are just as applicable to other similar sites, such as GitLab or Bitbucket.

There is so much that could be covered when describing how to use Git that it can be a challenge to focus on the essentials, as the title of the book implies. However, Ferdinando has achieved to do just that by making a very judicious use of references to easily accessible external references. The basic topics are well-presented, and pointers to find out more information are added just at the right time. My favorite example of this, which is something I learned from Ferdinando, is to write commit messages before writing the code. Ferdinando mentions this in Chapter 5, Obtaining the Most – Good Commits and Workflows, which briefly explains the rationale and includes a reference to a detailed blog post written by Arialdo Martini on this topic. Current Subversion users, who are considering starting using Git, will find Chapter 6, Migrating to Git, particularly useful.

Git Essentials is definitely not your traditional dry technical document. Ferdinando's writing style is not only that of a friendly conversation with a friend—one who is passionate about his or her favorite topic and eager to help you learn it—but also that of a friend who knows how to restrain his or her enthusiasm and teach you just enough to enable you to do what you need to do. He does this while giving you useful pointers in case you want to know more.

Dr. André Roberge

Former President and Vice-Chancellor of Université Sainte-Anne

About the Author

Ferdinando Santacroce is a developer, author, and teacher who loves learning new things.

As a software developer, Ferdinando mainly works on the .NET platform using C#, which bridges the gaps between oldstyle systems and new technologies. Over the span of his career, he has allowed COBOL applications to talk with remote services, databases, and electronic devices, such as cash handlers, scanners, and electronic shelf labels. At the moment, he's focusing on continuously improving the Agile Movement, which he follows with great care, in conjunction with XP foundations and lean manufacturing.

While working as a teacher, he developed the first web-based school register in a school of his district, which allowed parents to take a look at grades and absences on a regular basis.

Ferdinando loves to teach people, everyone from children to grandpas, and introduces them to the use of computers, the Internet, and new mobile devices.

He enjoys writing too; after a hiatus of a few years, he started blogging again about his work and passions, which, according to him, is more or less the same thing.

Most of what he's learned over the years has been with the help of his friends and colleagues. This has encouraged him to read books and attend inspiring conferences, such as XP Conference, Italian Agile Day, Codemotion, and others, that help his growth by working on the same code with him.

About the Reviewers

Fabrizio Donina is 34 years old. For 14 years, he worked at a steel plant. He has been involved in the management of industrial automation systems. He first gained experience on platforms, such as Siemens SCADA Cube, Access Database, and Oracle 8i. In recent years, he has had the opportunity to use different development environments, such as SCADA, FactoryTalk by Rockwell, iFix, and WinCC flexible by Siemens. Currently, he's programming PLC Siemens S7 300/400, performing diagnostics and fault searches. Over the years, he has been able to develop software with the help of VB6.0 and Oracle Forms and interface Oracle - > SAP, by implementing Oracle stored procedures for exchanging data. In recent years, he started programming the MES system, which is now in operation at the plant he's working in.

This is the first time he's been asked to review a book. So far, he's always read manuals that have already been published.

I would like to thank Ferdinando Santacroce who got me involved in this great experience.

Giovanni Giorgi is an IT professional with a strong cultural background, and is currently living in Milan, Italy.

Giovanni works for NTT Data and is involved in the IT banking and financial sectors; he's had more then 15 years of experience in Java-based solutions.

Born in 1974, he grew up with Mazinga Z, Daitarn 3, and 8-bit computers by Commodore.

In college, he studied Latin and Greek, along with Turbo Pascal and C programming language as a hobby.

He then started university in September 1993. After one year, he fell in love with the GNU open source philosophy and the Emacs text editor.

Giovanni got a master's degree in information technology from DSI in Milan, Italy, in 2000, and specialized in UML and design pattern integration.