web-dev-qa-db-ja.com

ブランチ作成以降のコミットを表示

git logまたはその他のコマンドで、ブランチの作成後に追加されたコミットのみを確認する方法はありますか?

usage: git log [<options>] [<since>..<until>] [[--] <path>...]
   or: git show [options] <object>...

    --quiet               suppress diff output
    --source              show source
    --decorate[=...]      decorate options
56
lurscher

3つの期間を使用して、2番目のブランチが最初のブランチから分岐したコミットを参照します。この場合、ブランチはマスターから分岐しました。

git log master...<your_branch_name>

この場合は、必ずthreeピリオドを使用してください。

サイドノート: gitは自動的にHEADポインターを参照するため、ブランチ名を省略することもできます。例:

git log master...

前の例と同等です。これは、コミット比較が利用可能な場所であればどこでも機能します。

55
Matt Meng

完全なドキュメントはこちら: https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html

次のようなリポジトリがあるとします:

base  -  A  -  B  -  C  -  D   (master)
                \
                 \-  X  -  Y  -  Z   (myBranch)

リポジトリステータスを確認します。

> git checkout master
Already on 'master'
> git status ; git log --oneline
On branch master
nothing to commit, working directory clean
d9addce D
110a9ab C
5f3f8db B
0f26e69 A
e764ffa base

myBranchの場合:

> git checkout myBranch
> git status ; git log --oneline
On branch myBranch
nothing to commit, working directory clean
3bc0d40 Z
917ac8d Y
3e65f72 X
5f3f8db B
0f26e69 A
e764ffa base

MyBranchにいて、マスターからの変更のみが必要だとします。 2ドットバージョンを使用します。

> git log --oneline master..myBranch
3bc0d40 Z
917ac8d Y
3e65f72 X

3ドットバージョンでは、masterの先端からmyBranchの先端までのすべての変更が提供されます。ただし、共通コミットBは含まれていないことに注意してください。

> git log --oneline master...myBranch
d9addce D
110a9ab C
3bc0d40 Z
917ac8d Y
3e65f72 X

注意:git logおよびgit diff BEHAVE DIFFERENTLY!動作は正反対ではありませんが、ほとんど:

> git diff master..myBranch
diff --git a/rev.txt b/rev.txt
index 1784810..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-D
+Z

> git diff master...myBranch
diff --git a/rev.txt b/rev.txt
index 223b783..e900b1c 100644
--- a/rev.txt
+++ b/rev.txt
@@ -1 +1 @@
-B
+Z

したがって、2ドットバージョンは、マスターの先端(つまりD)からmyBranchの先端(Z)までの差分を示します。 3ドットバージョンは、myBranchのベース(つまりB)からmyBranchの先端(Z)までの違いを示しています。

53
Alan Thompson

作成したブランチにいる場合:

git log master..
12
Shaun Luttin

はい、「新しい」ブランチとマスターブランチ(一般に「マスター」という名前)を比較することができます。

git log master..<your_branch_name>

もちろん、<your_branch_name>

3
Sandro Munda

私は間違っている可能性がありますが、OPで答えが正確に求められていたとは思わないので、新しい答えを追加したいと思いました。これは、他のソース管理システムでは非常に簡単なので、これはまったく同じ質問だと思います。

私はマスターに次のものを持っています:

「開発」| -> 'GP603'

Origin(私のローカルシステム)には:

'GP603' [リモート/ GP603ブランチから削除]

次に、2つの異なるコミットを実行しました。最初のコミット変更ファイルX。2番目のコミット変更ファイルXおよびファイルY。ある日後、ローカルブランチOrigin/GP603の状態の仮定を検証したかっただけです。これは、私が覚えているコミットが2回しかなかったことを検証するために行ったものです(実際にはブランチでコミットが2回しかなかった)

$ git log Origin/GP.603 ...

(コミット2)commit b0ed4b95a14bb1c4438c8b48a31db7a0e9f5c940(HEAD-> GP.603)作成者:xxxxxxx日付:水xxxxx -0400

1. Fixed defect where the format of the file names and paths were being added to HashTable in such a way that they would never be matched in any comparison.  This was an
defect causing older failed files to never be moved to the correct directory (WindowsServiceApplication.cs)

2. Removing worthless and contextless message as it does nothing but clog the log with garbage making it harder to read (DinoutFileHandler.cs)

(コミット1)コミット2c4541ca73eacd4b2e20d89f018d2e3f70332e7e著者:xxxxxxx日付:Tue Oct xxxxx -0400

In ProcessFile() function need to perform a .ToLower() on the file path string when adding it o the failedFiles collection.
0
Ethan Hodys