1,154 questions
2
votes
1
answer
64
views
How to compare the changes in two branches?
Say I have four commits A, B, C and D, with A being an ancestor of B and C being an ancestor of D. I now want to verify that the changes from A to B are the same as the changes from C to D (or show ...
-2
votes
1
answer
70
views
Optimized git diff --name-only
I believe the two functions below is the same. But AI keep telling me they are different (that I think AI is wrong).
get_changed_files() {
local staged_files committed_files
staged_files=$(git ...
-2
votes
2
answers
131
views
How to Use git diff to Show Specific Line Ranges (e.g., Lines 1–10 and 48–69) for a Commit
I want to prompt users in the documentation to directly review the message of a specific commit.
So, I’d like to use the git diff command, as shown below:
git --no-pager diff 0847759b^:path/a.cpp ...
0
votes
1
answer
119
views
Git diff when swapping statements
I have a the following piece of code in my git repo (using git version 2.33.0.windows.2):
int foo = 0;
// foo is set in some manner
if (foo == 1) {
DoA();
DoB();
DoC();
DoD();
}
if (...
0
votes
1
answer
120
views
What does `git diff` actually compare during a rebase conflict?
I have recently learned that git diff --cached shows how the new commit during an interactive rebase conflict after resolving the conflict looks. What does git diff compare during resolving a git ...
1
vote
0
answers
27
views
Can vimdiff do directory diffs? [duplicate]
I've been spoiled by GUI diff tools like meld, kdiff3 etc. Now I'm stuck having to do some git diff'ing via a terminal. If I:
git difftool --tool=vimdiff HEAD~
I get pairs of files which need to be ...
0
votes
1
answer
133
views
Show differences between commits with respect to a base
We use a common git strategy:
branch from main to a feature branch.
do commits in feature.
if main progresses, merge it to feature.
merge feature to main.
I want to view the changes that happened ...
0
votes
1
answer
99
views
Show a git merge commit in three-panel form in meld
This question shows many good ways to use git-mergetool to show the condition of files before a merge commit using meld:
Setting up and using Meld as your Git difftool and mergetool
I like the three-...
-2
votes
3
answers
210
views
Can git cherry-pick be replicated *exactly* with (git diff | git apply)?
I have a quite subtle script that's trying to patch differences from a formatted version of a text file to a "legacy" unformatted version. To help avoid issues with extraneous diffs due to ...
0
votes
1
answer
51
views
How can I tell a file was renamed using pygit2
I am running a diff between 2 consecutive commits and the only change between them is a rename of one file without any change in content involved. If I run a show on the parent commit, I get this from ...
0
votes
0
answers
71
views
How to achieve "git diff --numstat" with additional moved lines stats
This is for a javascript app, so no UI needed.
My goal is to get stats of changes between 2 commits, basically exactly what git diff --numstat does, but also, along with the additions and deletions ...
-5
votes
1
answer
151
views
How can I do a simple diff between two commits, uninfluenced by another other commits?
I thought I was beginning to understand git diff.
But today I did a git diff between a commit at the tip of one branch ("A") with a commit at the tip of another ("B"), where B is a ...
2
votes
2
answers
198
views
How to list changes in directory/tree mode in VS Code
I want to see the changes of git diff as a directory/tree list in VS Code. I remember it used to be there earlier in the git section of editor, but I don't see that anymore. Anyone knows how it can be ...
0
votes
2
answers
58
views
git diff: match includes too much
I need the diff (changes based on the words) between these two simple lines:
<h1>Intro line 06.03.2004</h1>
and:
<h1>Intro line 15.08.2024</h1>
The comparison command:
git ...
0
votes
0
answers
77
views
Is it possible to force `git add -p` to use a different diff algorithm without changing the repository config? [duplicate]
If I do the following:
git config diff.algorithm patience
git add -p
then git add -p forms its diffs using the patience algorithm. Is there any way to force git add -p to use patience as a one-off ...
1
vote
0
answers
56
views
Can I get git diff --stat to count character rather than lines added/removed?
I'm writing a patch for my code which mainly replaces contents within lines. I want the git diff --stat (and later git log --stat) to show me the numbers of characters, rather than lines, added or ...
0
votes
0
answers
72
views
Code disappears in target branch on git merge w/o any indication
I'm having a problem with Git merge. In short, I'm merging the master branch into a feature branch, essentially git checkout feature && git merge master.
This is how it looks graphically:
...
2
votes
1
answer
94
views
git log with all commits but partial diffs
I would like a way to log certain commits and also submit path arguments so that the diff on those paths, if any, is shown for each commit as if those path arguments were supplied like git diff -- <...
1
vote
2
answers
118
views
Make "git diff" output a remark when there is no difference
When the two commits are the same, git diff generates no result.
However, is there a way to make it output some text, such as "no difference in commit1 and commit2"? this is to help identify ...
1
vote
1
answer
114
views
List git changed files excluding what changed in the parent branch
I want to supply my linter tool with files that changed in my branch. The list should include:
files committed in my branch since branched from its parent
files changed and staged
files changed but ...
1
vote
1
answer
218
views
Show a combined diff of a merge commit, including added files by either parent branch
After doing a merge which includes changes of a coworker, I want to them, to outline wheat each of us changed and how I resolved the conflicts.
The standard way that git displays merges, however, is ...
1
vote
0
answers
46
views
View content that was added during the merge and comes from neither parent
During a merge with git 2.42.0.windows.2 and the Bash console, I had to manually perform some modifications to get it to compile, which I then committed along with the modifications due to the merge ...
1
vote
0
answers
70
views
git diff a file against the multiple files it was split into
I have a file A on branch old_branch that exists as multiple files A, B, C on a different branch new_branch. I need to merge old_branch into new_branch which would require me to resolve the merge ...
0
votes
1
answer
322
views
How to see incoming commits in IntelliJ IDEA similarly to VS Code
In VS Code, on Source Control view at left, you can see incoming changes grouped by commits. You can explore commits, see changed files, and examine individual changes.
In IntelliJ IDEA, there seems ...
0
votes
1
answer
104
views
Weird ^[[0K characters in git diff output (git delta)
I've been trying to make my git diff output nicer. Mainly I want side-by-side output, and so, I went with git-delta. Everything has been working great, but there is only one problem: git diff output ...