1,154 questions
2
votes
1
answer
61
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
97
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
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 ...
1
vote
1
answer
98
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
130
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
142
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
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 (...
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
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
votes
3
answers
192
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
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 ...
-2
votes
1
answer
168
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
132
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
172
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 ...
0
votes
1
answer
98
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-...
0
votes
1
answer
66
views
How can I get git diff to produce simpler output between 2 commits?
I have looked at many explanations about what git diff between 2 commits does, and I am still completely baffled about the output I am getting. I believe what I am seeing is "combined format"...
-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
93
views
Detect renames with `git difftool --dir-diff`
With git difftool --dir-diff, I can 'diff a whole tree by preparing a temporary copy'. However, I then lose information about renames. Here's a comprehensive example demonstrating the same.
git init
...
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 ...
2
votes
0
answers
128
views
Make git diff --color-moved machine readable?
Reading the git documentation and stuff online, it just mentions having the ability to change the colors of the moved lines when specifying --color-moved, but there is no mention of an option to ...
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 ...
0
votes
1
answer
123
views
How can I set the diff algorithm for a git diff on Azure Devops?
The --diff-algorithm option allows you to change how a diff is displayed - I use "histogram" to create a diffs that appear more logical to me when I'm running git on the command line.
How ...
-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 ...
0
votes
1
answer
56
views
List files 'deleted by us' in merge conflict
I have some merge conflicts on files 'deleted by us', meaning some incoming changes target files that I previously deleted. Is there some way in git to list these files (with the intent to git rm on ...
2
votes
2
answers
186
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
1
answer
88
views
Error: "patch does not apply" when manually editing diff
I have the following git diff for Python code:
@@ -520,7 +520,7 @@ class AreaManager:
self.broadcast_ooc(
f"[{client.id}] {client.showname} ({client.name}) is GM in this hub ...
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 ...
1
vote
1
answer
87
views
How to show the diff in all files having leftover conflict marker?
I know git diff --check will list all files having leftover conflict marker, but it doesn't actually show the diff. I think the command to show the diff in all files having leftover conflict marker ...
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 ...
0
votes
1
answer
67
views
How can I view manual changes so far in an ongoing merge?
In Git, my merge is still ongoing (no commit yet). 98% of the changes that show up in git diff are related to what MERGE_HEAD (and parent history singe merge-base) brought. 1% is my work from HEAD and ...
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
207
views
How to compare the DIFF of two merges/merge requests with different bases
Is there a good way to compare the diff (so basically the diff of the diff) between two merges or even better two potential merges (aka merge requests).
For some context the branching pattern: There ...
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:
...
0
votes
1
answer
54
views
How to compare a file on disk with a file from a different branch which does not exist on disk
I want to perform a comparison operation between a file which exists on disk and a file which no longer exists because I moved it.
Here's the situation.
I had a file which existed in a folder. Let's ...
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
1
answer
79
views
How can I ignore first x columns of the line with Git diff?
We have our COBOL-Sources now in GIT-repositories. During development nearly all devs are removing the cobol leading line squence numbers. So the git diff is showing all lines as changed.
I want that ...
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 ...
0
votes
1
answer
505
views
How to git diff on an Azure DevOps CI pipeline with more than one repository
There are a few helpful [questions and answers][1] online,
[1]: How to git diff on a Azure CI pipeline, but they seem to be working in a single-repository environment. I'm using one git repository for ...
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 ...
2
votes
1
answer
135
views
Git: Want to propagate (rebase) LF vs. CRLF changes through branch revisions
Say, I have a branch with several commits in it.
In versions A and B, I have a file with mixed line endings (mostly LF, but some CRLF), and made various other changes to it.
In version C, I made ...
1
vote
1
answer
216
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 ...
0
votes
0
answers
51
views
DiffMerge: Identical Files Marked As Inequivalent
I am comparing two folders, one I pulled down from GitHub and one that I've been working on locally and would like to push. DiffMerge displayed the files as different, as expected, so I went in and ...
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 ...
0
votes
1
answer
112
views
Git shows modified files with no actual differences
I'm working on a large and complex corporate project and I'm encountering an issue with Git and Visual Studio solution files (.sln). I have two .sln files that Git identifies as completely edited, but ...
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
0
answers
72
views
How to use git diff for modified files
Im trying to list all lines that have changed in modified files only, for this I'm using the following command
git diff --diff-filter=M
but still, I'm getting changes for new files that have been ...
0
votes
1
answer
313
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 ...
1
vote
2
answers
105
views
"git diff-index" showing unmodified files
I'm running the command git diff-index main in a repo that has the working tree equal to the branch main, but changes cached in the index. The command tells me that there are differences (I understand ...
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 ...
-1
votes
1
answer
126
views
Git diff shows difference between branches, but merge doesn't show all differences
I've got 2 branches I would like to merge: main and sub. In both branches there is a file called Math.java. This class contains one function on both branches: addition() on main and subtraktion() on ...