万本电子书0元读

万本电子书0元读

顶部广告

Mastering Git电子书

售       价:¥

14人正在读 | 0人评论 9.8

作       者:Jakub Narębski

出  版  社:Packt Publishing

出版时间:2016-04-01

字       数:871.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Attain expert-level proficiency with Git for enhanced productivity and efficient collaboration by mastering advanced distributed version control features About This Book Set up Git for solo and collaborative development Harness the full power of Git version control system to customize Git behavior, manipulate history, integrate external tools and explore platform shortcuts A detailed guide, which explains how to apply advanced Git techniques and workflows and ways to handle submodules Who This Book Is For If you are a Git user with reasonable knowledge of Git and familiarity with basic concepts such as branching, merging, staging, and workflows, this is the book for you. Basic knowledge of installing Git and software configuration management concepts is essential. What You Will Learn Explore project history, find revisions using different criteria, and filter and format how history looks Manage your working directory and staging area for commits and interactively create new revisions and amend them Set up repositories and branches for collaboration Submit your own contributions and integrate contributions from other developers via merging or rebasing Customize Git behavior system-wide, on a per-user, per-repository, and per-file basis Take up the administration and set up of Git repositories, configure access, find and recover from repository errors, and perform repository maintenance Chose a workflow and configure and set up support for the chosen workflow In Detail Git is one of the most popular types of Source Code Management (SCM) and Distributed Version Control System (DVCS). Despite the powerful and versatile nature of the tool enveloping strong support for nonlinear development and the ability to handle large projects efficiently, it is a complex tool and often regarded as “user-unfriendly”. Getting to know the ideas and concepts behind the architecture of Git will help you make full use of its power and understand its behavior. Learning the best practices and recommended workflows should help you to avoid problems and ensure trouble-free development. The book scope is meticulously designed to help you gain deeper insights into Git's architecture, its underlying concepts, behavior, and best practices. Mastering Git starts with a quick implementation example of using Git for a collaborative development of a sample project to establish the foundation knowledge of Git operational tasks and concepts. Furthermore, as you progress through the book, the tutorials provide detailed de*ions of various areas of usage: from archaeology, through managing your own work, to working with other developers. This book also helps augment your understanding to examine and explore project history, create and manage your contributions, set up repositories and branches for collaboration in centralized and distributed version control, integrate work from other developers, customize and extend Git, and recover from repository errors. By exploring advanced Git practices, you will attain a deeper understanding of Git’s behavior, allowing you to customize and extend existing recipes and write your own. Style and approach Step-by-step instructions and useful information make this book the ultimate guide to understanding and mastering Git. This book will show road to mastery example by example, while explaining mental model of Git. The Introduction section covers the 'Essentials' just for refreshing the basics. The main highlight is that the concepts are based on HOW the technology/framework works and not just practical 'WHAT to do'.
目录展开

Mastering Git

Table of Contents

Mastering Git

Credits

About the Author

About the Reviewer

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

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. Git Basics in Practice

An introduction to version control and Git

Git by example

Repository setup

Creating a Git repository

Cloning the repository and creating the first commit

Publishing changes

Examining history and viewing changes

Renaming and moving files

Updating your repository (with merge)

Creating a tag

Resolving a merge conflict

Adding files in bulk and removing files

Undoing changes to a file

Creating a new branch

Merging a branch (no conflicts)

Undoing an unpublished merge

Summary

2. Exploring Project History

Directed Acyclic Graphs

Whole-tree commits

Branches and tags

Branch points

Merge commits

Single revision selection

HEAD – the implicit revision

Branch and tag references

SHA-1 and the shortened SHA-1 identifier

Ancestry references

Reverse ancestry references: the git describe output

Reflog shortnames

Upstream of remote-tracking branches

Selecting revision by the commit message

Selecting the revision range

Single revision as a revision range

Double dot notation

Multiple points – including and excluding revisions

The revision range for a single revision

Triple-dot notation

Searching history

Limiting the number of revisions

Matching revision metadata

Time-limiting options

Matching commit contents

Commit parents

Searching changes in revisions

Selecting types of change

History of a file

Path limiting

History simplification

Blame – the line-wise history of a file

Finding bugs with git bisect

Selecting and formatting the git log output

Predefined and user defined output formats

Including, formatting, and summing up changes

Summarizing contributions

Viewing a revision and a file at revision

Summary

3. Developing with Git

Creating a new commit

The DAG view of creating a new commit

The index – a staging area for commits

Examining the changes to be committed

The status of the working directory

Examining differences from the last revision

Unified Git diff format

Selective commit

Selecting files to commit

Interactively selecting changes

Creating a commit step by step

Amending a commit

Working with branches

Creating a new branch

Creating orphan branches

Selecting and switching to a branch

Obstacles to switching to a branch

Anonymous branches

Git checkout DWIM-mery

Listing branches

Rewinding or resetting a branch

Deleting a branch

Changing the branch name

Summary

4. Managing Your Worktree

Ignoring files

Marking files as intentionally untracked

Which types of file should be ignored?

Listing ignored files

Ignoring changes in tracked files

File attributes

Identifying binary files and end-of-line conversions

Diff and merge configuration

Generating diffs and binary files

Configuring diff output

Performing a 3-way merge

Transforming files (content filtering)

Obligatory file transformations

Keyword expansion and substitution

Other built-in attributes

Defining attribute macros

Fixing mistakes with the reset command

Rewinding the branch head, softly

Removing or amending a commit

Squashing commits with reset

Resetting the branch head and the index

Splitting a commit with reset

Saving and restoring state with the WIP commit

Discarding changes and rewinding branch

Moving commits to a feature branch

Undoing a merge or a pull

Safer reset – keeping your changes

Rebase changes to an earlier revision

Stashing away your changes

Using git stash

Stash and the staging area

Stash internals

Un-applying a stash

Recovering stashes that were dropped erroneously

Managing worktrees and the staging area

Examining files and directories

Searching file contents

Un-tracking, un-staging, and un-modifying files

Resetting a file to the old version

Cleaning the working area

Multiple working directories

Summary

5. Collaborative Development with Git

Collaborative workflows

Bare repositories

Interacting with other repositories

The centralized workflow

The peer-to-peer or forking workflow

The maintainer or integration manager workflow

The hierarchical or dictator and lieutenants workflows

Managing remote repositories

The origin remote

Listing and examining remotes

Adding a new remote

Updating information about remotes

Renaming remotes

Changing the remote URLs

Changing the list of branches tracked by remote

Setting the default branch of remote

Deleting remote-tracking branches

Support for triangular workflows

Transport protocols

Local transport

Smart transports

Native Git protocol

SSH protocol

Smart HTTP(S) protocol

Offline transport with bundles

Cloning and updating with bundle

Using bundle to update an existing repository

Utilizing bundle to help with the initial clone

Remote transport helpers

Transport relay with remote helpers

Using foreign SCM repositories as remotes

Credentials/password management

Asking for passwords

Public key authentication for SSH

Credential helpers

Publishing your changes upstream

Pushing to a public repository

Generating a pull request

Exchanging patches

Chain of trust

Content-addressed storage

Lightweight, annotated, and signed tags

Lightweight tags

Annotated tags

Signed tags

Publishing tags

Tag verification

Signed commits

Merging signed tags (merge tags)

Summary

6. Advanced Branching Techniques

Types and purposes of branches

Long-running, perpetual branches

Integration, graduation, or progressive-stability branches

Per-release branches and per-release maintenance

Hotfix branches for security fixes

Per-customer or per-deployment branches

Automation branches

Mob branches for anonymous push access

The orphan branch trick

Short-lived branches

Topic or feature branches

Bugfix branches

Detached HEAD – the anonymous branch

Branching workflows and release engineering

The release and trunk branches workflow

The graduation, or progressive-stability branches workflow

The topic branches workflow

Graduation branches in a topic branch workflow

Branch management for a release in a topic branch workflow

Git-flow – a successful Git branching model

Fixing a security issue

Interacting with branches in remote repositories

Upstream and downstream

Remote-tracking branches and refspec

Remote-tracking branches

Refspec – remote to local branch mapping specification

Fetching and pulling versus pushing

Pull – fetch and update current branch

Pushing to the current branch in a nonbare remote repository

The default fetch refspec and push modes

Fetching and pushing branches and tags

Fetching branches

Fetching tags and automatic tag following

Pushing branches and tags

Push modes and their use

The simple push mode – the default

The matching push mode for maintainers

The upstream push mode for the centralized workflow

The current push mode for the blessed repository workflow

Summary

7. Merging Changes Together

Methods of combining changes

Merging branches

No divergence – fast-forward and up-to-date cases

Creating a merge commit

Merge strategies and their options

Reminder – merge drivers

Reminder – signing merges and merging tags

Copying and applying a changeset

Cherry-pick – creating a copy of a changeset

Revert – undoing an effect of a commit

Applying a series of commits from patches

Cherry-picking and reverting a merge

Rebasing a branch

Merge versus rebase

Types of rebase

Advanced rebasing techniques

Resolving merge conflicts

The three-way merge

Examining failed merges

Conflict markers in the worktree

Three stages in the index

Examining differences – the combined diff format

How do we get there: git log --merge

Avoiding merge conflicts

Useful merge options

Rerere – reuse recorded resolutions

Dealing with merge conflicts

Aborting a merge

Selecting ours or theirs version

Scriptable fixes – manual file remerging

Using graphical merge tools

Marking files as resolved and finalizing merges

Resolving rebase conflicts

git-imerge – incremental merge and rebase for git

Summary

8. Keeping History Clean

An introduction to Git internals

Git objects

The plumbing and porcelain Git commands

Environment variables used by Git

Environment variables affecting global behavior

Environment variables affecting repository locations

Environment variables affecting committing

Rewriting history

Amending the last commit

An interactive rebase

Reordering, removing, and fixing commits

Squashing commits

Splitting commits

Testing each rebased commit

External tools – patch management interfaces

Scripted rewrite with the git filter-branch

Running the filter-branch without filters

Available filter types for filter-branch and their use

Examples of using the git filter-branch

External tools for large-scale history rewriting

Removing files from the history with BFG Repo Cleaner

Editing the repository history with reposurgeon

The perils of rewriting published history

The consequences of upstream rewrite

Recovering from an upstream history rewrite

Amending history without rewriting

Reverting a commit

Reverting a faulty merge

Recovering from reverted merges

Storing additional information with notes

Adding notes to a commit

How notes are stored

Other categories and uses of notes

Rewriting history and notes

Publishing and retrieving notes

Using the replacements mechanism

The replacements mechanism

Example – joining histories with git replace

Historical note – grafts

Publishing and retrieving replacements

Summary

9. Managing Subprojects – Building a Living Framework

Managing library and framework dependencies

Managing dependencies outside Git

Manually importing the code into your project

A Git subtree for embedding the subproject code

Creating a remote for a subproject

Adding a subproject as a subtree

Cloning and updating superprojects with subtrees

Getting updates from subprojects with a subtree merge

Showing changes between a subtree and its upstream

Sending changes to the upstream of a subtree

The Git submodules solution: repository inside repository

Gitlinks, .git files, and the git submodule command

Adding a subproject as a submodule

Cloning superprojects with submodules

Updating submodules after superproject changes

Examining changes in a submodule

Getting updates from the upstream of the submodule

Sending submodule changes upstream

Transforming a subfolder into a subtree or submodule

Subtrees versus submodules

Use cases for subtrees

Use cases for submodules

Third-party subproject management solutions

Managing large Git repositories

Handling repositories with a very long history

Using shallow clones to get truncated history

Cloning only a single branch

Handling repositories with large binary files

Splitting the binary asset folder into a separate submodule

Storing large binary files outside the repository

Summary

10. Customizing and Extending Git

Git on the command line

Git-aware command prompt

Command-line completion for Git

Autocorrection for Git commands

Making the command line prettier

Alternative command line

Graphical interfaces

Types of graphical tools

Graphical diff and merge tools

Graphical interface examples

Configuring Git

Command-line options and environment variables

Git configuration files

The syntax of Git configuration files

Accessing the Git configuration

Basic client-side configuration

The rebase and merge setup, configuring pull

Preserving undo information – the expiry of objects

Formatting and whitespace

Server-side configuration

Per-file configuration with gitattributes

Automating Git with hooks

Installing a Git hook

A template for repositories

Client-side hooks

Commit process hooks

Hooks for applying patches from e-mails

Other client-side hooks

Server-side hooks

Extending Git

Command aliases for Git

Adding new Git commands

Credential helpers and remote helpers

Summary

11. Git Administration

Repository maintenance

Data recovery and troubleshooting

Recovering a lost commit

Troubleshooting Git

Git on the server

Server-side hooks

The pre-receive hook

Push-to-update hook for pushing to nonbare repositories

The update hook

The post-receive hook

The post-update hook (legacy mechanism)

Using hooks to implement the Git-enforced policy

Enforcing the policy with server-side hooks

Early notices about policy violations with client-side hooks

Signed pushes

Serving Git repositories

Local protocol

SSH protocol

Anonymous Git protocol

Smart HTTP(S) protocol

Dumb protocols

Remote helpers

Tools to manage Git repositories

Tips and tricks for hosting repositories

Reducing the size taken by repositories

Speeding up smart protocols with pack bitmaps

Solving the large nonresumable initial clone problem

Augmenting development workflows

Summary

12. Git Best Practices

Starting a project

Dividing work into repositories

Selecting the collaboration workflow

Choosing which files to keep under version control

Working on a project

Working on a topic branch

Deciding what to base your work on

Splitting changes into logically separate steps

Writing a good commit message

Preparing changes for submission

Integrating changes

Submitting and describing changes

The art of the change review

Responding to reviews and comments

Other recommendations

Don't panic, recovery is almost always possible

Don't change the published history

Numbering and tagging releases

Automate what is possible

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部