Skip to Content
実用 Git 第3版
book

実用 Git 第3版

by Prem Kumar Ponuthorai, Jon Loeliger, 萬谷 暢崇, 長尾 高弘
March 2024
Intermediate to advanced
576 pages
9h
Japanese
O'Reilly Japan, Inc.
Content preview from 実用 Git 第3版

9章コミットの書き換え

コミットは作業の履歴を記録したものであり、コードに加えた変更を神聖不可侵な存在として残し続ける。しかし、Gitはリポジトリにまとめられたコミット履歴を変更、改良するためのツールとコマンドも複数提供している。

1つのコミットを書き換えたり、コミットシーケンス全体を作り直したりする理由として正当なものはたくさんある。一部の例を挙げてみよう。

  • レガシーとして手を出せないものになる前に問題を修復したい。
  • 大規模で雑多な内容が含まれる1つの変更をテーマを持つ複数の小さなコミットに分割したい。逆に、細々とした小さな変更を結合して1つの大きなコミットにまとめたい。
  • プロジェクトの開発ライフサイクル全体を通じて、レビューによる問題点の指摘や提案を組み込みたい。
  • ビルド要件が変わらない範囲でコミットの順序を並べ替えたい。
  • コミットをより論理的な順序に並べ替えたい。
  • 間違ってコミットされたデバッグコードを取り除きたい。
  • 間違ってコミットされたコード内の機密データを取り除きたい†1

[†1] リモートリポジトリにコミットをプッシュしていなければ、その機密データはあなたのローカルリポジトリにあるだけだ。それでも、コミットを書き換え、参照されないコミットをローカルリポジトリから取り除くことはできる。

リポジトリの共有方法を説明する「11章 リモートリポジトリ」を読めばわかるように、リポジトリを公開する前にコミットを書き換える理由はほかにもたくさんある。

この章では、コミット履歴を書き換える根拠、書き換えの波及効果、コミット履歴に含まれる1個または一連のコミットを書き換えるためにGitが提供しているさまざまな方法を説明する。

Gitにコミットしたものは、Gitに留まり続ける(それがコミット履歴である)ことを忘れてはならない。コミットに対する小さな変更によってリポジトリ履歴全体の書き換えを余儀なくされるようなことがないように、コード内の機密データに関連した変更をどのように追跡し、バージョン管理するかについては細心の注意が必要とされる。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

LLMのプロンプトエンジニアリング ―GitHub Copilotを生んだ開発者が教える生成AIアプリケーション開発

LLMのプロンプトエンジニアリング ―GitHub Copilotを生んだ開発者が教える生成AIアプリケーション開発

John Berryman, Albert Ziegler, 服部 佑樹, 佐藤 直生
入門 Kubernetes

入門 Kubernetes

Kelsey Hightower, Brendan Burns, Joe Beda, 松浦 隼人
Binary Hacks Rebooted ―低レイヤの世界を探検するテクニック89選

Binary Hacks Rebooted ―低レイヤの世界を探検するテクニック89選

河田 旺, 小池 悠生, 渡邉 慶一, 佐伯 学哉, 荒田 実樹, 鈴木 創, 中村 孝史, 竹腰 開, 光成 滋生, hikalium, 浜地 慎一郎

Publisher Resources

ISBN: 9784814400614Publisher Website