単一のリポジトリで:
を使用して差分を調べることができるはずですがgit diff -- Vendor/JSONKit、ファイルをリセットする (そして変更を破棄する) だけの場合は、次のコマンドを発行します。
git checkout HEAD -- Vendor/JSONKit
これにより、作業ディレクトリ内の の最新バージョンがチェックアウトVendor/JSONKitされ、変更が破棄されます。
サブモジュールを含むリポジトリ:
Git サブモジュールを使用すると、git リポジトリを相互に埋め込むことができます。「JSONKit」が「MyApp」内のサブモジュールであるとします。最上位の git リポジトリである は、 のコミットMyAppのみを追跡するため、履歴の任意の時点でとの両方の状態を完全に再構築できます。HEADJSONKitMyAppJSONKit
JSONKitリポジトリ内で変更をコミットしたとします。内部JSONKitでは、これは通常の diff のように見え、通常の履歴があります。親リポジトリ内では、コミットMyAppへの変更として登録されます。git scm docsHEADから取得したこの diff のように見えるかもしれません。この例のサブモジュールは、「rack」というディレクトリです。
$ git diff --cached rack
diff --git a/rack b/rack
new file mode 160000
index 0000000..08d709f
--- /dev/null
+++ b/rack
@@ -0,0 +1 @@
+Subproject commit 08d709f78b8c5b0fbeb7821e37fa53e69afcf433
どのMyAppディレクトリがサブモジュールであるかをどのように知るのですか? ファイル内で追跡され.gitmodulesます。catに登録されているすべてのサブモジュールが表示されMyAppます。
$ cat .gitmodules
[submodule "rack"]
path = rack
url = git://github.com/chneukirchen/rack.git
を発行したとき、親リポジトリのインデックスにある のgit submodule update最新のHEADコミットをチェックアウトするように git に指示したため、サブモジュール リポジトリの変更が破棄されました。JSONKit
update
Update the registered submodules, i.e. clone missing submodules and checkout the commit specified in the index of the containing repository. This will
make the submodules HEAD be detached unless --rebase or --merge is specified or the key submodule.$name.update is set to rebase, merge or none. none
can be overridden by specifying --checkout.