Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Git Version Control Cookbook

You're reading from   Git Version Control Cookbook 90 hands-on recipes that will increase your productivity when using Git as a version control system

Arrow left icon
Product type Paperback
Published in Jul 2014
Publisher
ISBN-13 9781782168454
Length 340 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Olsson Olsson
Author Profile Icon Olsson
Olsson
 Voss Voss
Author Profile Icon Voss
Voss
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Git Version Control Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Navigating Git FREE CHAPTER 2. Configuration 3. Branching, Merging, and Options 4. Rebase Regularly and Interactively, and Other Use Cases 5. Storing Additional Information in Your Repository 6. Extracting Data from the Repository 7. Enhancing Your Daily Work with Git Hooks, Aliases, and Scripts 8. Recovering from Mistakes 9. Repository Maintenance 10. Patching and Offline Sharing 11. Git Plumbing and Attributes 12. Tips and Tricks Index

Displaying the tree information


It can sometimes be useful to show or find information on certain trees and files in Git. Here, the ls-tree and diff-tree commands come in handy. Essentially, these are plumbing commands, and they can sometimes be very useful when scripting or browsing.

Getting ready

We'll use the same repository as the previous example:

$ git clone https://github.com/dvaske/data-model.git

We also need a bare repository for some examples; it will by default, with the --bare option, be cloned to data-model.git, so remember which repository you are currently working on:

$ git clone --bare https://github.com/dvaske/data-model.git
$ cd data-model

How to do it...

To show the content of the current tree in the Git context, we can use the ls-tree command. We'll pass --abbrev to the command to limit the SHA-1 ID to its abbreviated form. This is usually seven characters:

$ git ls-tree --abbrev HEAD
100644 blob f21dc28  README.md
040000 tree abc267d  a_sub_directory
100644 blob b50f80a...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images