You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking for git diff in gert two compare to refs .
I found git_diff which can only display the changes in the passed ref, which is the most basic function of git diff.
Is there a way to compare two refs (e.g. two branches) with gert and find the changed files between them (git diff --name-only branch1 branch2)?
Right. But only files changed in this commit. (or current working dir vs. last commit)
Not the changed files between two commits as you would with git diff ref1 ref2 -- (--name-only just for better readability):
$> git diff --name-only main run-on-change --
API
NAMESPACE
R/core.R
R/source.R
R/utils.R
inst/script.R
man/add_lib_dirs.Rd
man/benchmark_run_ref.Rd
tests/testthat/test-utils.R
I am looking for this behaviour because I want to run some tests/benchmarks on pull requests only if the relevant file has changed between the branches (e.g. main and devel), so it would not be enough to only check the files changed in the last/one specific commit.
For now I can use system but I would rather use your great package to do it within R 😃
I'm working on adding git support to btw (i.e. tools for LLMs) using gert, and as requested here it would be very helpful for git_diff() to be able to provide a unified diff between two arbitrary refs.
An interface like this would be awesome:
git_diff("main..run-on-change") # shows unified diff of changes in run-on-change branch
git_diff("HEAD~2..HEAD") # shows unified diff of the last three commits
In other words, I'm thinking of something similar to GitHub's /compare endpoint with ref_base..ref_compare syntax.
Alternatively, it could be a new function, git_diff_compare():
git_diff_compare(base="main", compare="run-on-change")
# or
git_diff_compare(ref_base="main", ref_compare="run-on-change")
# or
git_diff_compare(start="main", end="run-on-change")
Without this, git_diff() is limited to returning the diff of a single commit, i.e. git_diff("run-on-change") shows the diff of the last commit in the run-on-change branch, which is useful but limited.
Activity
jeroen commentedon Aug 30, 2021
git_diff()returns a data frame, with a column containing the file name for each change? For example:Shows the files changed in your most recent commit.
assignUser commentedon Aug 30, 2021
Right. But only files changed in this commit. (or current working dir vs. last commit)
Not the changed files between two commits as you would with
git diff ref1 ref2 --(--name-only just for better readability):$> git diff --name-only main run-on-change -- API NAMESPACE R/core.R R/source.R R/utils.R inst/script.R man/add_lib_dirs.Rd man/benchmark_run_ref.Rd tests/testthat/test-utils.RI am looking for this behaviour because I want to run some tests/benchmarks on pull requests only if the relevant file has changed between the branches (e.g. main and devel), so it would not be enough to only check the files changed in the last/one specific commit.
For now I can use
systembut I would rather use your great package to do it within R 😃edit: And thank you for your quick response!
gadenbuie commentedon Oct 16, 2025
I'm working on adding git support to btw (i.e. tools for LLMs) using gert, and as requested here it would be very helpful for
git_diff()to be able to provide a unified diff between two arbitrary refs.An interface like this would be awesome:
In other words, I'm thinking of something similar to GitHub's
/compareendpoint withref_base..ref_comparesyntax.Alternatively, it could be a new function,
git_diff_compare():Without this,
git_diff()is limited to returning the diff of a single commit, i.e.git_diff("run-on-change")shows the diff of the last commit in therun-on-changebranch, which is useful but limited.maelle commentedon Apr 10, 2026
@gadenbuie would you want to open a PR? 😸