如何找到在git分支之间更改的公共文件? [英] How do I find common files changed between git branches?

查看:143
本文介绍了如何找到在git分支之间更改的公共文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个上游存储库有一些变化。我想对上游变更进行重新设置,以实现本地更改。我想知道我在本地更改了哪些文件也改变了上游,所以我可以检查任何自动合并。另外,我想在rebase期间手动进行任何合并。

解开方案

扩展了一下:问题,建立一个新的分支,自动完成rebase,然后和你的工作副本进行比较。

  git branch workBranch 
git commit#将你的本地人引入你自己的分支中一小段时间
git branch testBranch
git rebase otherBranch
git diff workBranch

你也可能只是做一个git diff origin / branchToMerge而已。



部分:

  git rebase --interactive。 

将所有提交设置为编辑,然后通过每个提交一次 - 让您有机会看到为该提交完成的所有操作,并编辑您心中的内容。 编辑回答评论



好吧,对于严格看到更改的文件,请执行以下操作:

  git log a0a0a0 .. b1b1b1  - 仅限名称--pretty = oneline | egrep -v'^ [a-f0-9] {40}'|排序| uniq> lista 
git log a0a0a0..c2c2c2 --name-only --pretty = oneline | egrep -v'^ [a-f0-9] {40}'|排序| uniq> listb
cat lista listb |排序| uniq -d

这个shell kludgery只显示两个日志中的文件。对于a0a0a0,请使用您的共同点。用两个分支分支的尖端替换b1 / c2字符串。


I have an upstream repository with some changes. I have local changes I want to rebase onto the upstream changes. I want to know what files I've changed locally have also changed upstream so I can check any automatic merging. Alternatively, I'd like to manually do any merges during the rebase.

解决方案

Expanded a bit: for you first part of the question, make a new branch, automatically do the rebase there, and then compare to your working copy.

git branch workBranch
git commit #throw your locals into your own branch for a brief moment
git branch testBranch
git rebase otherBranch
git diff workBranch

You might also get away with just doing a "git diff origin/branchToMerge"

For the interactive part:

git rebase --interactive.

Set all the commits to "Edit" and you'll be taken through each of them one-by-one giving you a chance to see everything done for that commit and edit to your heart's content.

EDIT to answer comment

OK, for strictly seeing changed files, do:

git log a0a0a0..b1b1b1 --name-only --pretty=oneline | egrep -v '^[a-f0-9]{40} ' | sort | uniq > lista
git log a0a0a0..c2c2c2 --name-only --pretty=oneline | egrep -v '^[a-f0-9]{40} ' | sort | uniq > listb
cat lista listb | sort | uniq -d

That bit of shell kludgery will show you only files that changed in both logs. For a0a0a0, use your common point. Replace the b1/c2 strings with the tips of the two diverging branches.

这篇关于如何找到在git分支之间更改的公共文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆