Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Git for Programmers
Git for Programmers

Git for Programmers: Master Git for effective implementation of version control for your programming projects

By Jesse Liberty
$54.99
Book Jun 2021 264 pages 1st Edition
eBook
$43.99
Print
$54.99
Subscription
$15.99 Monthly
eBook
$43.99
Print
$54.99
Subscription
$15.99 Monthly

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Table of content icon View table of contents Preview book icon Preview Book

Git for Programmers

Introduction

In this chapter, we will cover the following topics:

  • A very brief history of version control and Git
  • Getting and setting up Visual Studio 2019, GitHub Desktop, and your terminal
  • Getting and installing Git
  • Configuring Git for Visual Studio, GitHub Desktop, and GitHub at the command line

Let's get started!

About this book

"Begin at the beginning," the King said gravely, "and go on till you come to the end, then stop." – Alice in Wonderland

In this book, we will cover Git from the very beginning all the way through to advanced topics. No experience with Git is expected. Though if you have been using Git, you'll probably want to skim the initial chapters. Git is arguably the most popular version control system in the world, but this raises the question: "What is version control?"

Version control

Before version control, I would code a bit and then when I became afraid of losing that code, I would make a backup of my directory. This is slow, inefficient, takes up a lot of disk space, and is very hard to share with others.

A Version Control System (VCS) does all this work for you (and more) and does so in a way that is fast, efficient, and takes up a minimum of disk space. One of the fastest and most efficient is Git, although there are others. This book will not spend a lot of time convincing you that Git is better than the others. First, the market has spoken, and Git prevails. Second, if you've purchased this book, you've already decided. And if you haven't already purchased this book, go do so. I'll wait here.

About the code examples

In order to demonstrate the use of Git, we need to have a small program that we can evolve. The code examples are given in C#, but they are so simple that you'll be able to follow them regardless of your experience with the language. For example, if you can figure out what this does, you're all set.

public class Program
{
    public void PrintHello()
    {
        Console.WriteLine("Hello World!");
    }
}

This code declares a class (don't worry about what that is) named Program. Inside that class is a method (function) called PrintHello that prints Hello World to the console (your screen).

This is about as complex as it gets, and I'll explain each code snippet as we go.

Just a brief history

In July of 2005, after just a few month's work, Linus Torvalds, the genius behind Linux, released Git to meet his own needs, the needs of the Linux community, and eventually, the rest of us. The goal of Git was to be fast and efficient. It succeeded.

While most VCSes at the time were centralized (all the files were kept on a big server), Git uses a distributed system, in which everyone has their own repository. Technically, no central server is required for Git, although if you are working in a team, a central place for sharing code is convenient. But the huge difference is that with Git, the vast majority of your interactions with the VCS are local – right there on your disk.

Tools for working with Git

There are a number of easily confused terms (such as Git versus GitHub) and there are many tools for working with Git – from the command line to Graphical User Interface (GUI) tools. This section will review some of these options.

GitHub, et al.

There are many services that allow you to create shared "repositories" (the location of all the versions of your program). The most famous and popular are GitHub and Microsoft's Azure, as well as BitBucket and GitLab. Azure is a very powerful system for DevOps, while GitHub is a very straightforward way to host your program. We'll be using GitHub in this book. (Recently, Microsoft acquired GitHub for $7.5 billion in stock – and made a huge commitment to GitHub, open source and, of course, to Git.)

Key point: Git is the system we're covering in this book. GitHub is a central repository system for sharing code (we'll make this more specific later in the...

Getting Git

The very first thing you need to do is to install Git on your computer. The official Git site states that "even if Git is already installed on your computer, it is probably a good idea to reinstall to update to the latest version."

Getting Git on Windows

There are also a few ways in which to install Git on Windows. I recommend using the official build. The most recent one is available from the Git website: https://git-scm.com/download/win.

Another way to get Git, and to kill two birds with one stone, is to download and install GitHub Desktop. The installer will also install a command-line version of Git. You can get it at https://desktop.github.com/:

Figure 1.6: Obtaining GitHub Desktop

This book will show its demonstrations on Windows 10, using Git version 2.30.0.windows.2, but the examples should work with just about any version of Git.

Getting Git on a Mac

There are several ways to install Git on a Mac. The easiest is probably...

Configuring Git – the command line

We'll look at configuring Git to personalize throughout this book, but for now, let's add your name and email address so that every entry into Git is stamped appropriately. Enter the command-line command:

git config --global --edit

This will bring up your editor. Find or create the [user] section and add the following:

[user]
name = Jesse Liberty
email = jesseliberty@gmail.com

You will probably want to use your own name and email address.

There are other entries in the config file. Ignore them for now and save and close the file.

Configuring Git – Visual Studio

In Visual Studio for Windows, click on the Git menu and a dialog box will open. On the first tab, enter your username and email address:

Figure 1.8: Setting Git options in Visual Studio

Configuring Git – GitHub Desktop

To configure GitHub Desktop, you'll need an account on GitHub. We'll cover that in the next chapter. Once you do have an account, go to File | Options, select the Accounts tab, and then click on Sign in:

Figure 1.9: Setting up GitHub Desktop

Summary

In this chapter you saw an introduction to the book, listing what is in each chapter. You also saw a quick history of version control and of Git itself.

Next, we took a look at downloading the environments you'll need to follow along: Visual Studio 2019, GitHub Desktop, and PowerShell as your command line. All of these can be obtained for free.

Once the software was downloaded, we looked at how to set up Git, and how to set up the tools we'll be using.

Left arrow icon Right arrow icon

Key benefits

  • Master Git and maintain your projects better through version control
  • Get to grips with Git’s typical workflows, advanced functions, and their implementations
  • Learn the key Git commands to better manage your repository

Description

Whether you’re looking for a book to deepen your understanding of Git or a refresher, this book is the ultimate guide to Git. Git for Programmers comprehensively equips you with actionable insights on advanced Git concepts in an engaging and straightforward way. As you progress through the chapters, you’ll gain expertise (and confidence) on Git with lots of practical use cases. After a quick refresher on git history and installation, you’ll dive straight into the creation and cloning of your repository. You’ll explore Git places, branching, and GUIs to get familiar with the fundamentals. Then you’ll learn how to handle merge conflicts, rebase, amend, interactive rebase, and use the log, as well as explore important Git commands for managing your repository. The troubleshooting part of this Git book will include detailed instructions on how to bisect, blame, and several other problem handling techniques that will complete your newly acquired Git arsenal. By the end of this book, you’ll be using Git with confidence. Saving, sharing, managing files as well as undoing mistakes and basically rewriting history will be a breeze.

What you will learn

Create remote and local repositories and learn how to clone them Understand the difference between local and remote repositories Use, manage, and merge branches back into the main branch Utilize tools to manage merge conflicts Manage commits on your local machine through interactive rebasing Use the log to gain control over all the data in your repository Use bisect, blame, and other tools to undo Git mistakes
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Country selected

Publication date : Jun 30, 2021
Length 264 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781801075732
Category :
Concepts :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Black & white paperback book shipped to your address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now
Estimated delivery fee Deliver to South Korea

Standard delivery 10 - 13 business days

$12.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details


Publication date : Jun 30, 2021
Length 264 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781801075732
Category :
Concepts :

Table of Contents

16 Chapters
Preface Chevron down icon Chevron up icon
1. Introduction Chevron down icon Chevron up icon
2. Creating Your Repository Chevron down icon Chevron up icon
3. Branching, Places, and GUIs Chevron down icon Chevron up icon
4. Merging, Pull Requests, and Handling Merge Conflicts Chevron down icon Chevron up icon
5. Rebasing, Amend, and Cherry-Picking Chevron down icon Chevron up icon
6. Interactive Rebasing Chevron down icon Chevron up icon
7. Workflow, Notes, and Tags Chevron down icon Chevron up icon
8. Aliases Chevron down icon Chevron up icon
9. Using the Log Chevron down icon Chevron up icon
10. Important Git Commands and Metadata Chevron down icon Chevron up icon
11. Finding a Broken Commit: Bisect and Blame Chevron down icon Chevron up icon
12. Fixing Mistakes Chevron down icon Chevron up icon
13. Next Steps Chevron down icon Chevron up icon
14. Other Books You May Enjoy Chevron down icon Chevron up icon
15. Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%
Top Reviews
No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela