Git Apprentice by By Chris Belanger

Git Apprentice by By Chris Belanger

Author:By Chris Belanger
Language: eng
Format: epub
Publisher: Ray Wenderlich


Limiting results

This is straightforward; simply execute the following command to show the number of commits you’d like to see, starting from the most recent:

git log -3

Git will then show you just the three most recent commits. You can replace the 3 in the above example to show any number of commits you’d prefer.

That’s a little more manageable, but there’s still a lot of detail in there. Wouldn’t it be nice if there was a way to view just the commit messages and filter out all the other, extra information?

There is! Execute the following command to see a more compact view of the repository history:

git log --oneline

You’ll see a quick, compact view of the commit history, which is arguably far more readable than the original output from git log:

~/GitApprentice/ideas $ git log --oneline 477e542 (HEAD -> master) Adding .gitignore files and HTML ffcedc2 Adds all the good ideas about management 8409427 Removes terrible live streaming ideas 67fd0aa Moves platform ideas to website directory 0ddfac2 Updates book ideas for Symbian and MOS 6510 6c88142 Adding some tutorial ideas . . .

This also shows you the short hash of a commit. Although you haven’t looked at hashes in depth yet, there are long and short hashes for each commit that uniquely identify a commit within a repository.

For instance, if I take a look at the first line of the most recent commit on my repo with git log -1 (that’s the number “1”, not the letter “l”), I see the following:

commit 477e542bfa35942ddf069d85fbe3fb0923cfab47 (HEAD -> master)

Now, to compare, I look at that same single commit with git log -1 --oneline (yes, you can stack multiple options with git log), I get the following:

477e542 (HEAD -> master) Adding .gitignore files and HTML

The short hash is simply the first seven characters of the long hash; in this case, 477e542. For the average-sized development project, seven hexadecimal digits provides you with more than a quarter of a billion short hashes, so the possibility of hashes colliding between various commits is quite small.

When you ramp up to massively-sized Git repositories that live on for years, or even decades, the chance of two commits having the same hash becomes a reality.

Older versions of Git allowed you to configure the number of hash characters to use for your repository, but more recent versions of Git (from about 2017 onward) dynamically adapt this setting to suit the size of your project, so you don’t usually have to worry about it.

Note: Are you wondering why some options to commands are preceded with a single dash, while others are preceded with double dashes?

This has its roots way back in the history of command-line-based operating systems. Generally, commands that have double dashes are the “long form” of a command, and are there for clarity.

For instance, the command git log -p, which you’ve used before, shows the diffs of your commits. But there’s another command that only differs by the fact that the option is in uppercase: git log -P, which does something entirely different.

Since



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Eco-friendly approach of bio-indigo synthesis and developing purification methods towards isolation of indigo from indirubin and bacterial fragments by Ramalingam Manivannan & Kaliyan Prabakaran & Young-A Son(212976)
Personalized inhaled bacteriophage therapy for treatment of multidrug-resistant Pseudomonas aeruginosa in cystic fibrosis by unknow(181452)
CONSORT 2025 statement: updated guideline for reporting randomized trials by unknow(89884)
Critical evaluation of the ProfiLER-02 study design and outcomes by Vivek Subbiah & Razelle Kurzrock(89496)
Cardiac gene therapy makes a comeback by Oliver J. Müller & Susanne Hille & Anca Kliesow Remes(89255)
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(74452)
Unveiling the design rules for tunable emission in graphene quantum dots: A high-throughput TDDFT and machine learning perspective by Şener Özönder & Mustafa Coşkun Özdemir & Caner Ünlü(50905)
A yeast-based oral therapeutic delivers immune checkpoint inhibitors to reduce intestinal tumor burden by unknow(40275)
Covalent hitchhikers guide proteins to the nucleus by Alexander F. Russell & Madeline F. Currie & Champak Chatterjee(40220)
Meet the Authors: Christopher R. Mansfield and Emily R. Derbyshire by Christopher R. Mansfield & Emily R. Derbyshire(40104)
Alkaline-earth metals promote propane dehydrogenation with carbon dioxide through geometric effects: Altering the reaction pathway by unknow(32741)
Induced iron vacancies boosting FeOOH loaded on sustainable Fenton-like collagen fiber membrane for efficient removal of emerging contaminants by unknow(32522)
Efficient electric-field-assisted photochemical conversion of methane to n-propanol exclusively over penetrated TiO2Ti hollow fibers by Guanghui Feng(32460)
Bi2SiO5 nanosheets as piezo-photocatalyst for efficient degradation of 2,4-Dichlorophenol by Hangyu Shi & Yifu Li & Lishan Zhang & Guoguan Liu & Qian Zhang & Xuan Ru & Shan Zhong(32400)
A novel NDIPTA organic heterojunction photocatalyst with built-in electric field for efficient hydrogen production by Jiahui Yang & Baojun Ma & Yongfa Zhu(32372)
Enhanced conversion of methane to liquid-phase oxygenates via hollow ferrite nanotube@horseradish peroxidase based photoenzymatic catalysis by Jun Duan & Shiying Fan & Xinyong Li & Shaomin Liu(32338)
Ordered macroporous superstructure of defective carbon adorned with tiny cobalt sulfide for selective electrocatalytic hydrogenation of cinnamaldehyde by Xiao-Shi Yuan & Sheng-Hua Zhou & San-Mei Wang & Wenbo Wei & Xiaofang Li & Xin-Tao Wu & Qi-Long Zhu(32263)
What's Done in Darkness by Kayla Perrin(27155)
Topological analysis of non-conjugated ethylene oxide cored dendrimers decorated with tetraphenylethylene: Insights from degree-based descriptors using the polynomial approach by A Theertha Nair & D Antony Xavier & Annmaria Baby & S Akhila(26542)
Investigation of mechanical and self-healing properties of hydroxyl-terminated polybutadiene functionalized with 2-ureido-4-pyrimidinone by Mohsen Kazazi & Mehran Hayaty & Ali Mousaviazar(26469)