- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
是否可以通过 git add --patch
配置 Git 以使用我配置的 difftool?
我想通过我自己的 difftool 选择要添加到索引的更改。
最佳答案
不,不幸的是。
我想我可以看到工作 - Git 根据当前索引中的内容生成一个临时文件,将其与当前工作树版本的副本一起交给 difftool(以保护您免于进行进一步更改),让我们您使用 difftool 将一些更改移动到索引版本,然后在保存并退出后,暂存该修改后的索引版本中的任何内容。请注意,这将需要 difftool 也有点像编辑器,但并非所有有效的 difftools 都是;其中一些仅用于查看差异。另请注意,这基本上绕过了所有 git add -p
。您不会从它那里获得任何用于在 hunk 之间移动、拆分 hunk 等的正常界面。 difftool 将完全负责所有这些。
如果您的 difftool 功能齐全,足以执行此类操作,那么我想您可以编写一个脚本来执行此操作。一个大纲,实际上没有任何错误保护、特殊情况的处理(二进制文件?),并且完全未经测试:
#!/bin/bash
tmpdir=$(mktemp -d)
git diff --name-only |
while read file; do
cp "$file" $tmpdir
# this has your changes in it
work_tree_version="$tmpdir/$file"
# this has the pristine version
index_version=$(git checkout-index --temp "$file")
# and now you bring changes from the work tree version into the index version,
# within the difftool, and save the index version and quit when done
my_difftool "$work_tree_version" "$index_version"
# swap files around to run git add
mv "$file" "$work_tree_version"
mv "$index_version" "$file"
git add "$file"
mv "$work_tree_version" "$file"
# you could also do this by calculating the diff and applying it directly to the index
# git diff --no-index -- "$file" "$original_index_version" | git apply --cached
rm -r $tmpdir
可能有很多方法可以改进它;抱歉,我现在没有时间仔细和彻底地处理它。
关于git add --patch with difftool,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9023928/
这个问题在这里已经有了答案: Why does "git difftool" not open the tool directly? (2 个答案) 关闭 6 年前。 当使用 git difftoo
我有 2 个文件夹(具有不同的代码)并初始化了 git。但是当我这样做的时候 git difftool -t meld 一个存储库运行良好,并询问我是否要在 meld 中打开文件进行比较。另一个只是在
我正在使用 kdiff3 作为 difftool。当我使用 git difftool 命令时,它还会向我显示完全相同的文件。甚至 kdiff3 也会 pop 一条消息,指出这些文件是“二进制相等的”(
当我执行 git difftool 时,我收到消息 Hit return to launch 'araxis':。我发现我可以通过按 CTRL-C 来终止整个比较,但是跳过单个文件怎么样? 这可能吗?
我的 ~/.gitconfig 中有以下配置 [diff] tool = vimdiff [diftool] prompt = false 当我启动 git difftool 时,它默
是否可以让 git difftool 命令打开一个目录,比较更改的文件和暂存/检查的文件? 理想情况下,如果有 2 个文件已更改,它们将是唯一显示的 2 个,但在目录比较中。 我读过有关让 git 并
我已将我的 git difftool 设置为使用 winmerge。它已经工作了很长一段时间。但是今天突然不行了。 git difftool 曾经在脏文件上一个接一个地调用 winmerge,但现在不
我已将 Meld 配置为我的 difftool。我很确定它配置正确,因为如果我这样做 git config -l ,我得到 merge.tool=meld diff.tool=meld mergeto
我正在尝试在 Windows 8.1 系统上的 Git Bash 中使用 KDiff3 作为 difftool,我承认我对 Git 很陌生。当我尝试将暂存文件与提交文件进行比较时,我无法打开 KDif
我已经将 Beyond Compare 配置为 difftool。 当我运行 $ git difftool 时,它会打开 BC 中的所有 diff 文件,但顺序是,即第一个 diff 文件打开,我必须
我使用 Windows 版 git bash 和 Beyond & Compare 作为我的差异工具(但同样的事情发生在任何外部差异工具上)。 我希望我的终端不要等待 difftool 退出以返回终端
我在文件 .gitconfig 中为 KDiff3 配置了以下 difftool, [difftool "kdiff3"] external = '"C:/Program Files/KDif
看来git difftool执行外部命令时,没有正确引用参数。 如果 .gitconfig 包含以下几行: [difftool.echo] cmd = echo "$LOCAL" "$REMOTE
我有许多新文件以及一些已添加到我的分支的修改过的文件,当我执行 git difftool master 时,它会比较所有修改过的文件并打开所有新文件。我看到类似的东西 Launching WinMer
我这样配置 git: git config --global diff.tool meld 当我运行时: git difftool 我收到以下消息: Viewing: 'hello.txt' Hit
是否可以通过 git add --patch 配置 Git 以使用我配置的 difftool? 我想通过我自己的 difftool 选择要添加到索引的更改。 最佳答案 不,不幸的是。 我想我可以看到工
默认的 git diff 行为是依次打开每个 diff 文件(在打开下一个文件之前等待上一个文件关闭)。 我正在寻找一种同时打开所有文件的方法 - 例如,在 BeyondCompare 中,这将在同一
这个问题在这里已经有了答案: Show both staged & working tree in git diff? (3 个答案) 关闭 5 年前。 有没有办法查看同一文件的 staged 和
当使用“git difftool”时,当其中一个文件是最新版本时,它会将相对路径传递给外部 diff 应用程序。 ~/.gitconfig [difftool "echo"] cmd = ec
我想在单一 View 中查看对所有文件的更改,如图所示;最好选择两个修订版并从 GUI 启动 diff。 我能得到的最接近的是启动 git difftool -t meld -d 2e9c5b 4fc
我是一名优秀的程序员,十分优秀!