识别推送中的所有提交
Identify all commits made in a push
我正在配置 TeamCity 服务器,我需要知道如何识别单次推送中提交的所有文件。
例如:
- 用户提交 1:
- file1.c
- file2.c
- 用户通讯 2:
- file1.c
- fileX.c
- fileY.c
我需要将所有这些文件分组,以便为此 "push" 命令构建 1 个版本。有一个 git 命令可以做到这一点?
谢谢。
您可以显示 git 日志并处理结果:
列出最后一次提交:
git log --name-status -p -1
result:
commit d1bc9d55024e4e3e6acc087ba223bd7951b555fa
Author: unknown <johndoe>
Date: Wed Oct 7 16:20:27 2015 -0300
task1000 commit message here...
M file1.c
M file2.c
现在,列出消息中带有 "task1000" 的所有提交:
git log --name-status --grep="task1000"
result:
commit d1bc9d55024e4e3e6acc087ba223bd7951b555fa
Author: unknown <johndoe>
Date: Wed Oct 7 16:20:27 2015 -0300
task1000 commit message here...
M file1.c
M file2.c
commit 998a74eaa752f6c98c32ec9a412b219afb7cc891
Author: unknown <johndoe>
Date: Wed Oct 7 16:19:56 2015 -0300
task1000 more one commit for this task..
M file1.c
M fileX.c
M fileY.c
现在你必须处理这个结果。
您需要关注服务器中的每一次提交。
您可以使用
$ git diff --name-only <your commit range>
例如,
$ git diff --name-only HEAD~3..HEAD
config/sidekiq.yml
deploy/before_migrate.rb
deploy/before_restart.rb
您可以在 post-receive
挂钩(如 said in the docs)中使用它,如下所示:
#!/usr/bin/env ruby
$oldrev = ARGV[1]
$newrev = ARGV[2]
`git diff --name-only #{$oldrev}..#{$newrev} > listing.txt`
我正在配置 TeamCity 服务器,我需要知道如何识别单次推送中提交的所有文件。
例如:
- 用户提交 1:
- file1.c
- file2.c
- 用户通讯 2:
- file1.c
- fileX.c
- fileY.c
我需要将所有这些文件分组,以便为此 "push" 命令构建 1 个版本。有一个 git 命令可以做到这一点?
谢谢。
您可以显示 git 日志并处理结果:
列出最后一次提交:
git log --name-status -p -1
result:
commit d1bc9d55024e4e3e6acc087ba223bd7951b555fa
Author: unknown <johndoe>
Date: Wed Oct 7 16:20:27 2015 -0300
task1000 commit message here...
M file1.c
M file2.c
现在,列出消息中带有 "task1000" 的所有提交:
git log --name-status --grep="task1000"
result:
commit d1bc9d55024e4e3e6acc087ba223bd7951b555fa
Author: unknown <johndoe>
Date: Wed Oct 7 16:20:27 2015 -0300
task1000 commit message here...
M file1.c
M file2.c
commit 998a74eaa752f6c98c32ec9a412b219afb7cc891
Author: unknown <johndoe>
Date: Wed Oct 7 16:19:56 2015 -0300
task1000 more one commit for this task..
M file1.c
M fileX.c
M fileY.c
现在你必须处理这个结果。
您需要关注服务器中的每一次提交。
您可以使用
$ git diff --name-only <your commit range>
例如,
$ git diff --name-only HEAD~3..HEAD
config/sidekiq.yml
deploy/before_migrate.rb
deploy/before_restart.rb
您可以在 post-receive
挂钩(如 said in the docs)中使用它,如下所示:
#!/usr/bin/env ruby
$oldrev = ARGV[1]
$newrev = ARGV[2]
`git diff --name-only #{$oldrev}..#{$newrev} > listing.txt`