标签: git-diff

将Git Diff限制为一个或多个函数?

我开始*.py diff=python了.git/info/attributes.所以Git知道功能界限在哪里.git diff -W甚至可以确保显示整个功能.

但有没有办法将git diff的输出限制为特定的函数(或多个函数)?

(没错,我猜它很糟糕......)

编辑这也将是有益的git log和git rev-list:不显示我的每一个承诺会修改views.py,告诉我犯这是修改某个功能.(是的,在一个理想的世界里,views.py不会是一个经常被8个不同的开发者修改的2000行庞然大物...)

git git-diff git-log

11
推荐指数
1
解决办法
2353
查看次数

git diff :: overriding .gitconfig外部工具

我已配置git为meld用作外部差异工具:

$ cat ~/.gitconfig | grep -A2 "\[diff\]"
[diff]
        tool = vimdiff
        external = git-meld
Run Code Online (Sandbox Code Playgroud)

......在哪里git-meld:

$ cat $(which git-meld)
#!/bin/bash
meld $2 $5
Run Code Online (Sandbox Code Playgroud)

但有时候(例如在非常小的差异或者我想从diff文本中轻松复制粘贴的东西的情况下)我只想看到shell上的差异并避免meld产生延迟.

有没有办法(例如命令行参数)覆盖.gitconfig设置并指示git只做一个简单的纯文本差异?

git git-diff meld

11
推荐指数
2
解决办法
3706
查看次数

gitpython和git diff

我期待只从git repo改变文件的差异.现在,我正在使用gitpython来实际获取提交对象和git文件的更改,但我想对仅更改的文件部分进行依赖性分析.有没有办法从git python获取git diff?或者我是否必须通过逐行阅读来比较每个文件?

git git-diff gitpython

11
推荐指数
3
解决办法
2万
查看次数

Git - 在meld(作为difftool)中所做的更改未保存

我在这篇文章中关注了JörgWMittag 的回答,并将meld配置为我的git中的difftool.现在,我可以使用此命令完美地查看和比较不同分支中文件的差异:

git checkout branch1
git difftool branch1:file.f90 branch2:file.f90
Run Code Online (Sandbox Code Playgroud)

我执行了上面的命令,制作并保存了变化.但是,当我使用以下方法检查文件时:

emacs file.f90
Run Code Online (Sandbox Code Playgroud)

我之前在meld中所做的更改根本没有保存.我不明白为什么会这样; 我必须没有完全正确配置融合作为差异工具.任何人都可以帮我解决这个问题吗?谢谢!!

git git-diff meld

11
推荐指数
3
解决办法
2617
查看次数

如何获得git子树差异?

我有一个已安装另一个存储库的存储库

git subtree add -P some/path  otherremote otherbranch
Run Code Online (Sandbox Code Playgroud)

开发已经发生了一些局部变化,但也进行了几轮合并:

git fetch otherremote
git subtree merge -P some/path otherremote/otherbranch
git commit
Run Code Online (Sandbox Code Playgroud)

现在我想在otherremote/otherbranch的HEAD和某些/ path的树之间获得差异.我怎样才能做到这一点?

git git-diff git-subtree

11
推荐指数
1
解决办法
3630
查看次数

(git)diff输出相对路径?

我需要在我的仓库中获得一些与仓库基础无关的差异,而是相对于给定的基础或给定路径.

我默认得到:

git diff
diff --git a/path/to/file b/path/to/file
index 0cc125e..9bf911e 100644
--- a/path/to/file
+++ b/path/to/file
Run Code Online (Sandbox Code Playgroud)

但我想要的是:

git diff --prefix=/new/path/to
diff --git a/new/path/to/file b/new/path/to/file
index 0cc125e..9bf911e 100644
--- a/new/path/to/file
+++ b/new/path/to/file
Run Code Online (Sandbox Code Playgroud)

我查看了--relative选项(不是我要找的), - src/dst-prefix(这些只能改变"a"或"b"部分.我错过了一些基本的东西吗?

git diff patch git-diff difference

11
推荐指数
2
解决办法
8389
查看次数

使用difftool在同一文件的分阶段和非分阶段版本之间的差异

有没有办法查看同一文件的版本staged和unstaged版本之间的差异?

例如:

Changes to be committed:

    modified:   conf/application.conf

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   conf/application.conf
Run Code Online (Sandbox Code Playgroud)

当我进行更改然后再次修改文件而不进行暂存时会发生这种情况.

EDIT

该git status -vv命令还不够好,因为我需要使用diff/ difftool命令.这是因为在实践中,太多文件中的更改太多,滚动浏览所有文件并不高效.但diff/ difftool允许我指定我感兴趣的文件.

git diff git-diff difftool git-stage

11
推荐指数
1
解决办法
7293
查看次数

如何使用git比较文件的工作副本,登台副本和提交的副本

假设我有一个名为LICENSE.txt的存储库中的文件.内容如下:

Copyright 2014 MyCompany. All Rights Reserved.
Run Code Online (Sandbox Code Playgroud)

自2015年以来,我改变了今年的2015年:

Copyright 2015 MyCompany. All Rights Reserved.
Run Code Online (Sandbox Code Playgroud)

然后上传文件

git add LICENSE.txt
Run Code Online (Sandbox Code Playgroud)

由于分心,我对LICENSE.txt做了另一个更改,以反映另一个组织的版权.

Copyright 2015 MyCompany and Affiliates. All Rights Reserved.
Copyright 2015 Other Company. All Rights Reserved.
Run Code Online (Sandbox Code Playgroud)

通过运行,我能够看到我的工作副本和分阶段副本之间的区别

git diff 
Run Code Online (Sandbox Code Playgroud)

我可以通过运行看到分阶段副本和提交副本之间的区别

git diff --cached
Run Code Online (Sandbox Code Playgroud)

如何将承诺的副本(没有更改年份的副本)与工作副本(具有附加版权的副本)进行比较?

这纯粹是一个例子.有些情况要复杂得多,我需要将我上演的内容与我随后对文件所做的更改进行比较.比较工作副本和分阶段副本的内容将决定是否应该替换分阶段副本.

我在Windows Server 2012 R2上运行git 1.9.5.

git git-diff

10
推荐指数
2
解决办法
7962
查看次数

在git status之后git diff-files输出更改

我有一个脚本,update.py它下载我的git存储库中跟踪的新版本文件:

$ python update.py
Doing work...
Done
$ git status
On branch my-branch
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   foo.txt
    modified:   bar.txt
    modified:   baz.txt

no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)

有时,下载的文件与已有的文件相同HEAD,因此下载后工作目录是干净的:

$ python update.py
Doing work...
Done
$ git status
On branch my-branch
nothing to commit, working directory clean …
Run Code Online (Sandbox Code Playgroud)

git git-diff

10
推荐指数
1
解决办法
643
查看次数

`git diff -w` (或 `--ignore-all-space`)已损坏

根据官方git 文档:

git diff
    -w, --ignore-all-space
           Ignore whitespace when comparing lines. This ignores differences
           even if one line has whitespace where the other line has none.
Run Code Online (Sandbox Code Playgroud)

然而,基本测试表明事实并非如此。

复制步骤:

  1. somefile.txt使用以下内容 创建:
    • 第 1 行:任何您想要的文本
    • 第 2 行:任何非零数量的空格
    • 第 3 行:任何您想要的文本
  2. git add somefile.txt
  3. cp somefile.txt somefile.orig.txt
  4. 调整somefile.txt:
    • 第 1 行:进行任何您想要的更改
    • 第 2 行:删除所有空格(现在将是空行)
    • 第 3 行:请勿更改此行
  5. 使用git diff创建所谓的“忽略空白”差异:git diff -w somefile.txt > somefile.gitdiff
  6. 使用 GNU diff创建一个真正忽略空白的 diff :diff -uw somefile.orig.txt somefile.txt > …

git diff git-diff

10
推荐指数
1
解决办法
1309
查看次数

标签 统计

git ×10

git-diff ×10

diff ×3

meld ×2

difference ×1

difftool ×1

git-log ×1

git-stage ×1

git-subtree ×1

gitpython ×1

patch ×1