Add diff snippets
This commit is contained in:
17
snippets/difference-between-branches.md
Normal file
17
snippets/difference-between-branches.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: View difference between two branches
|
||||
tags: branch,intermediate
|
||||
---
|
||||
|
||||
Displays the difference between two branches.
|
||||
|
||||
- Use `git diff <branch>..<other-branch> ` to view the difference between `<branch>` and `<other-branch>`.
|
||||
|
||||
```sh
|
||||
git diff <branch>..<other-branch>
|
||||
```
|
||||
|
||||
```sh
|
||||
git diff patch-1..patch-2
|
||||
# Displays the difference between branches `patch-1` and `patch-2`
|
||||
```
|
||||
21
snippets/view-differences.md
Normal file
21
snippets/view-differences.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
title: View differences in changes
|
||||
tags: commit,branch,intermediate
|
||||
---
|
||||
|
||||
Displays differences between staged or unstaged changes and the last commit.
|
||||
|
||||
- Use `git diff` to view differences between your unstaged changes and the last commit.
|
||||
- You can use the `--staged` option to view differences between your staged changes and the last commit instead.
|
||||
|
||||
```sh
|
||||
git diff [--staged]
|
||||
```
|
||||
|
||||
```sh
|
||||
git diff
|
||||
# Displays the differences between unstaged changes and the last commit
|
||||
|
||||
git diff --staged
|
||||
# Displays the differences between staged changes and the last commit
|
||||
```
|
||||
Reference in New Issue
Block a user