1,155 questions
0
votes
2
answers
77
views
Can I make `git diff` generate a patch ignoring changes in comments?
I'm trying to use git diff to generate a patch file, which I can then give to diff2html to render into a nice page.
However, I'd like to have my patch only contain differences which are in non-comment ...
2
votes
1
answer
76
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 ...
-3
votes
1
answer
133
views
On macOS, Git does not automatically pick up the .gitattributes settings
Below is the result of my directory tree:
$ tree -a
myapp
├── .git
├── .gitattributes
└── assets
└── my.ttf
When I run the following command in the assets directory on my Mac Mini M4 Pro:
cd ...
-2
votes
1
answer
76
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 ...
1
vote
1
answer
106
views
Does `git diff` pass down its own arguments to sub-commands?
Summary / Question
Does git diff pass arguments provided to it down through to sub commands (e.g. git grep) when invoked? For example, when calling git diff -G with an additional flag of -i as well (e....
-2
votes
2
answers
137
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
2
answers
157
views
Using bash variables instead of files as input to git commands
I have a script which sets useful git settings and aliases, and I want to end by printing the difference between git config --global --list before and after. I'd like to show the diff in the same ...
0
votes
1
answer
121
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 (...
2
votes
2
answers
161
views
why this bash script works?
git diff normally will not generate an output, if the two commits it compares are identical, to make it generate explicitly "the two commits are the same", I found the bash script below.
...
0
votes
1
answer
128
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
votes
3
answers
196
views
Git difftool to open untracked files
I have configured P4V to work with my git difftool command.
I have added (unstaged) some new files to a new folder.
Is there a way I can run git difftool on the folder to show the newly added files in ...
1
vote
0
answers
29
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 ...
-2
votes
1
answer
169
views
Git diff command that shows differences in words as a whole and in any single character that isn't alphanumeric
I am using git to help me manage a text, and I need git to show me changes in each word as a whole, and in the punctuation and in the spacing as well.
Let's say I have a sentence I hold the big target,...
0
votes
1
answer
134
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 ...
-2
votes
3
answers
182
views
How can I work on multiple git branches at once?
Clarification: I'm asking about working on multiple branches in the same worktree. (I know how to work on multiple branches in separate worktrees, but that's not the question here.)
Suppose I'm ...