[英]How can I check if a file has forward progress on another branch?
Our team is using git
for version control. 我们的团队正在使用git
进行版本控制。
When each team member is assigned a programming task, 为每个团队成员分配编程任务后,
they branch off our dev
branch, and onto their own issue-#
branch. 他们从我们的dev
分支分支到自己的issue-#
分支。
With many unmerged issue branches in progress, 许多未合并的问题分支正在进行中,
how can I evaluate whether a particular file has forward progress, and on what branches? 如何评估特定文件是否具有转发进度以及在哪个分支上进行?
Example, 例,
I would like to checkout the dev
branch, 我想签出dev
分支,
and run a command that gives results similar to: 并运行一条命令,其结果类似于:
dev/issue-34 (20 insertions / 5 deletions)
dev/issue-71 (60 deletions)
for a particular queried file. 用于特定的查询文件。
A command that filters through hundreds of branches, and informs me who has edited a paritcular file thus far. 该命令可过滤数百个分支,并通知我到目前为止谁编辑过一个偶数文件。
As a basis, you can use 作为基础,您可以使用
git diff --numstat dev origin/issue-34
to get a list of files with number of new/deleted lines between dev
and a given issue branch. 获取具有dev
和给定问题分支之间的新行/已删除行数的文件列表。
You'd want to use the git for-each-ref
command to cycle through the branches of interest, then dump out a diff stat on any changes. 您可能想使用git for-each-ref
命令来遍历感兴趣的分支,然后对所有更改转储diff统计信息。
In the below script it presumes you are checked out to your dev branch, that you have a remote origin that it is getting the branches from, and that you are in the root directory and are passing in the full path and name of the file of interest. 在下面的脚本中,它假定您已签出到dev分支,您具有从其获取分支的远程来源,并且您位于根目录中,并且正在传递文件的完整路径和名称。利益。 It also is lacking error checking but should have the basic functionality you need. 它还缺少错误检查,但应具有所需的基本功能。
#!/bin/sh
# $1 is the name of the file we are interested in
baseSha=$(git rev-parse HEAD:$1)
git for-each-ref --format="%(refname)" refs/remotes/origin/dev/* | \
while read dev_branch
do
echo "Checking ${dev_branch}"
branchSha=$(git rev-parse ${dev_branch}:$1)
if [ ${baseSha} != ${branchSha} ]
then
git diff --stat HEAD..${dev_branch} -- $1
else
echo "No changes"
fi
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.