English 中文(简体)
git 分散指挥,排除一些文件夹和档案
原标题:git diff command to exclude some folders and files
  • 时间:2018-01-25 01:18:55
  •  标签:
  • git
  • gerrit

我目前正在使用以下Gitediff指挥系统,以改变档案清单。 我想排除某些文件夹(datafiles)和文档()。 DSstore。 是否有办法这样做?

git diff --no-index /Users/USERNAME/Documents/FWintegration/ingo2/ukon_4355c1 /Users/USERNAME/Documents/FWintegration/ingo2mirror/ingo2mirror
问题回答

Okay...my第三次回答。 不幸的是,这是最>的复杂,但实际使用的是--no-index:

git diff | awk  {if (/^diff --git/) {if (/d1/S*$/){display=0}else{display=1}};if (display==1) {print}} 

每一文档都以“diff - git”为起点。 因此,我们非常看着这条线。 如果它发现它,那么它就停止印刷,直到它发现一个iff子。

So, the only part of the awk statement you modify is if (/d1/S*$/) This is how it filters...if this regular expression matches, it ll ignore this diff--not print it). This filters out "d1/" followed by any number of non-whitespace characters up until the end of the line (so it s looking at the 2nd filename only and not the first.) For your example, you d want the if to be:

if (/datafiles/S*$/ || /.DSstore$/)

EDIT: If this is too insane for you, and no one provides a better solution, I d highly recommend checking out "Beyond Compare" which is a crazy powerful directory/file comparison tool with a nice UI.

git diff --  :!unwantedpath 

For example, git diff -- :!foo/bar/datafiles :!*.DSstore .

但它是一个相对较新的特点,因此只有在你使用新的Gite版本时才会发挥作用。 我不记得介绍过哪一个版本,但是,在2.10.0之后,它有了一个版本。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签