简体   繁体   English

如何检查文件在另一个分支上是否有前进进度?

[英]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.

相关问题 如何检查分支是否已合并到另一个分支? - How can I check whether a branch has been merged into another branch? 如何使用git将另一个分支中的文件签出到当前分支的新文件中? - How can I check out a file from another branch into a new file in the current branch with git? Git:我忘记创建分支 master,如果我的存储库已经有另一个分支,我该如何创建它? - Git: i forgot create branch master, how i can create it if my repository already has another branch? 如何检查git branch是否有跟踪分支? - How do I check if git branch has a tracking branch? 如何在git中将文件历史记录从一个分支合并到另一个分支? - How can I merge a file history from a branch to another in git? 如何将正在进行的本地 master 和分支移动到另一台笔记本电脑? - How do I move a local master and branch in progress to another laptop? 如何从另一个分支分支,然后删除源分支? - How can I branch from another branch, then delete origin branch? 如何将所有文件和文件夹从一个分支替换/复制到GIT中的另一个现有分支 - How Can I replace/copy all file and folder from one branch to another existing branch in GIT 如何将一个分支中的特定文件合并到Git中的另一个分支中 - How can I merge a specific file from one branch into another branch in Git 如何快速将分支转发到另一个非主分支 - How to fast forward a branch to another non-master branch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM