Skip to content

Commit

Permalink
TIL: diff and merge files
Browse files Browse the repository at this point in the history
  • Loading branch information
pew committed Dec 27, 2024
1 parent 46e769c commit 1e05bb4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions man/diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
date created: Friday, December 27th 2024, 11:01:17 am
date modified: Friday, December 27th 2024, 11:05:51 am
tags:
- diff
- vimdiff
---

# diff

## compare files

- **side-by-side comparison**: `diff -y file1 file2`
- **unified format**: `diff -u file1 file2`
- **ignore whitespace differences**: `diff -w file1 file2`

## merge files

### vimdiff

- Use `dp` (put changes) and `do` (get changes) to merge

```shell
vimdiff file1 file2
```

- sometimes, vimdiff copies more than you want, try the following:

```shell
:diffget .
#:diffput .
```

if you get `more than one match for .`, mark the whole line with `v` and use `:diffget`

### sdiff

- step-by-step side-by-side merging:

```shell
sdiff -o mergedfile file1 file2
```

0 comments on commit 1e05bb4

Please sign in to comment.