Notas de Hongmu

git diff

显示已跟踪文件的内容变更

100% Procesamiento local del navegador 0 Carga de datos

Ejemplos comunes

显示未暂存的更改

git diff

显示所有未提交的更改(包括已暂存的)

git diff HEAD

仅显示已暂存(添加过但未提交)的更改

git diff --staged

显示过去某段时间内所有提交的变更(日期表达式如“1 week 2 days”或 ISO 日期)

git diff 'HEAD@{{{3 months|weeks|days|hours|seconds ago}}}'

显示差异统计信息(如文件变更列表、直方图及总行数增删)

git diff --stat {{提交}}

输出自某次提交以来的文件创建、重命名及权限变更的摘要

git diff --summary {{提交}}

比较两个分支或提交之间的单个文件

git diff {{分支1}}..{{分支2}} {{路径/到/文件}}

将当前分支的某文件与其他分支的对应文件进行对比

git diff {{分支}}:{{路径/到/文件2}} {{路径/到/文件}}

Consejo: llaves{{…}}Es el parámetro que necesita ser reemplazado (ruta, nombre de archivo, etc.); el comando solo se ejecuta en la terminal local y este sitio no guarda ninguna entrada.

Comparación del texto original en inglés.

Ampliar instrucciones y ejemplos en inglés (fuente tldr-pages)

Show changes to tracked files. More information

Show unstaged changes

git diff

Show all uncommitted changes (including staged ones)

git diff HEAD

Show only staged (added, but not yet committed) changes

git diff --staged

Show changes from all commits since a given date/time (a date expression, e.g. "1 week 2 days" or an ISO date)

git diff 'HEAD@{{{3 months|weeks|days|hours|seconds ago}}}'

Show diff statistics, like files changed, histogram, and total line insertions/deletions

git diff --stat {{commit}}

Output a summary of file creations, renames, and mode changes since a given commit

git diff --summary {{commit}}

Compare a single file between two branches or commits

git diff {{branch_1}}..{{branch_2}} {{path/to/file}}

Compare different files from the current branch to another branch

git diff {{other_branch}}:{{path/to/file2}} {{path/to/file1}}

información de comando

nombre del comandogit diff
Uso显示已跟踪文件的内容变更
Plataformas aplicables通用
Número de ejemplos8 artículo
Documentación oficialhttps://git-scm.com/docs/git-diff
Fuente de datostldr-pages(CC-BY-4.0)· Traducción de chino comunitario

Preguntas frecuentes

git diff ¿Qué hace el comando?

显示已跟踪文件的内容变更

git diff ¿Cómo usarlo?

Páginas enumeradas por escena8Ejemplos de uso común: cada ejemplo primero explica el propósito y luego brinda un comando completo que se puede copiar directamente (los parámetros que deben reemplazarse están entre llaves).

git diff ¿Cuáles son las operaciones más utilizadas?

显示未暂存的更改:git diff

¿Qué significan las llaves en el comando?

Corchetes{{…}}Indica que debe reemplazarlo con su propio valor, como la ruta y el nombre del archivo; corchetes para parámetros con el mismo nombre (como[-C|--directory]) indica escritura opcional.