Edits: changes in specific file between commits/branches

There is one more way to show changes in the same file
between two different commits or branches. It looks simpler:
'git diff' [options] <commit> <commit> [--] [<path>...]

This should work for git version 2.13.0:
https://github.com/git/git/blob/v2.13.0/Documentation/git-diff.txt#L14
This commit is contained in:
apastan 2023-01-11 13:33:22 +03:00
parent 3d101f5456
commit 1ef224ede3
6 changed files with 25 additions and 1 deletions

View File

@ -1829,12 +1829,16 @@ Assuming you want to compare last commit with file from commit c5f567:
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# or
$ git diff HEAD c5f567 -- path_to_file/file
```
Same goes for branches:
If you are going to compare changes between the tips of the `main` and the `staging` branches:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# or
$ git diff main staging -- path_to_file/file
```
### I want Git to ignore changes to a specific file

View File

@ -1450,12 +1450,16 @@ Supposons que vous voulez comparer le dernier commit avec le fichier du commit `
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# ou
$ git diff HEAD c5f567 -- path_to_file/file
```
Il en est de même pour les branches :
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# ou
$ git diff main staging -- path_to_file/file
```
### Je veux que Git ignore les changements d'un fichier spécifique

View File

@ -1873,12 +1873,16 @@ $ git push origin refs/tags/<tag-name>
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# または
$ git diff HEAD c5f567 -- path_to_file/file
```
ブランチでも同様です。
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# または
$ git diff main staging -- path_to_file/file
```
### 特定のファイルの変更を無視したい

View File

@ -1409,12 +1409,16 @@ c5f567 한 단계전으로 복구하고 싶다면, c5f567~1로 적어줘요:
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# 아니면 짧게:
$ git diff HEAD c5f567 -- path_to_file/file
```
브랜치도 같은 방법으로:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# 아니면 짧게:
$ git diff main staging -- path_to_file/file
```
## 설정

View File

@ -1681,12 +1681,16 @@ $ git push origin refs/tags/<tag-name>
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# или
$ git diff HEAD c5f567 -- path_to_file/file
```
Аналогично для веток:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# или
$ git diff main staging -- path_to_file/file
```
### Я хочу, чтобы Git игнорировал изменения в определенном файле

View File

@ -1776,12 +1776,16 @@ Giả sử bạn muốn so sánh commit cuối cùng với tệp từ commit c5f
```sh
$ git diff HEAD:path_to_file/file c5f567:path_to_file/file
# hoặc
$ git diff HEAD c5f567 -- path_to_file/file
```
Cũng giống khi so sánh nhánh nhánh:
```sh
$ git diff main:path_to_file/file staging:path_to_file/file
# hoặc
$ git diff main staging -- path_to_file/file
```
### Tôi muốn Git bỏ qua những thay đổi đối với một tệp cụ thể