git_diff
git diff is a conflict detection checker that scans files for Git conflict markers and other merge-related issues that may have been inadvertently left in the codebase after resolving merge conflicts.
Key Features:
- Conflict Marker Detection: Identifies Git conflict markers (
<<<<<<<,=======,>>>>>>>) that weren't properly resolved - Merge Safety: Prevents accidentally committing unresolved merge conflicts to version control
- Repository Hygiene: Helps maintain clean codebases by catching leftover merge artifacts
- Fast Scanning: Efficiently processes files to detect problematic patterns without performance overhead
git_diff documentation
- Version in MegaLinter: 2.54.0
- Visit Official Web Site
Configuration in MegaLinter
- Enable git_diff by adding
REPOSITORY_GIT_DIFFin ENABLE_LINTERS variable - Disable git_diff by adding
REPOSITORY_GIT_DIFFin DISABLE_LINTERS variable
| Variable | Description | Default value |
|---|---|---|
| REPOSITORY_GIT_DIFF_ARGUMENTS | User custom arguments to add in linter CLI call Ex: -s --foo "bar" |
|
| REPOSITORY_GIT_DIFF_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter Ex: -s --foo "bar" |
|
| REPOSITORY_GIT_DIFF_CLI_LINT_MODE | Override default CLI lint mode ⚠️ As default value is project, overriding might not work - file: Calls the linter for each file- list_of_files: Call the linter with the list of files as argument- project: Call the linter from the root of the project |
project |
| REPOSITORY_GIT_DIFF_PRE_COMMANDS | List of bash commands to run before the linter | None |
| REPOSITORY_GIT_DIFF_POST_COMMANDS | List of bash commands to run after the linter | None |
| REPOSITORY_GIT_DIFF_UNSECURED_ENV_VARIABLES | List of env variables explicitly not filtered before calling REPOSITORY_GIT_DIFF and its pre/post commands | None |
| REPOSITORY_GIT_DIFF_DISABLE_ERRORS | Run linter but consider errors as warnings | false |
| REPOSITORY_GIT_DIFF_DISABLE_ERRORS_IF_LESS_THAN | Maximum number of errors allowed | 0 |
| REPOSITORY_GIT_DIFF_CLI_EXECUTABLE | Override CLI executable | ['git'] |
MegaLinter Flavors
This linter is available in the following flavors
| Flavor | Description | Embedded linters | Info | |
|---|---|---|---|---|
![]() |
all | Default MegaLinter Flavor | 137 | |
| c_cpp | Optimized for pure C/C++ projects | 60 | ||
| ci_light | Optimized for CI items (Dockerfile, Jenkinsfile, JSON/YAML schemas,XML | 24 | ||
| cupcake | MegaLinter for the most commonly used languages | 93 | ||
| documentation | MegaLinter for documentation projects | 53 | ||
| dotnet | Optimized for C, C++, C# or VB based projects | 68 | ||
| dotnetweb | Optimized for C, C++, C# or VB based projects with JS/TS | 77 | ||
| go | Optimized for GO based projects | 55 | ||
| java | Optimized for JAVA based projects | 58 | ||
| javascript | Optimized for JAVASCRIPT or TYPESCRIPT based projects | 63 | ||
| php | Optimized for PHP based projects | 58 | ||
| python | Optimized for PYTHON based projects | 70 | ||
| ruby | Optimized for RUBY based projects | 54 | ||
| rust | Optimized for RUST based projects | 54 | ||
| salesforce | Optimized for Salesforce based projects | 57 | ||
| swift | Optimized for SWIFT based projects | 54 | ||
| terraform | Optimized for TERRAFORM based projects | 57 |
Behind the scenes
How are identified applicable files
- If this linter is active, all files will always be linted
How the linting is performed
git_diff is called once on the whole project directory (project CLI lint mode)
- filtering can not be done using MegaLinter configuration variables,it must be done using git_diff configuration or ignore file (if existing)
VALIDATE_ALL_CODEBASE: falsedoesn't make git_diff analyze only updated files
Example calls
git diff --check
Help content
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]
[--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]
[--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
backfill Download missing objects in a partial clone
branch List, create, or delete branches
commit Record changes to the repository
history EXPERIMENTAL: Rewrite history
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Set `HEAD` or the index to a known state
switch Switch branches
tag Create, list, delete or verify tags
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
Installation on mega-linter Docker image
None
