0284437acb66a3856a8a63b4648a7ac5d5f23881
programming/git.md
| ... | ... | @@ -53,6 +53,36 @@ compare diff between two commits |
| 53 | 53 | git diff <commit>...<commit> |
| 54 | 54 | ``` |
| 55 | 55 | |
| 56 | +compare file diff between two branches |
|
| 57 | +``` |
|
| 58 | +git diff newbranch main -- file.txt |
|
| 59 | +git diff newbranch..main -- file.txt |
|
| 60 | +``` |
|
| 61 | +using the latter syntax, if either side is `HEAD` it may be ommitted (e.g., `main..` compares `main` to `HEAD`) |
|
| 62 | + |
|
| 63 | +adding separate hunks from file |
|
| 64 | +``` |
|
| 65 | +git add --patch <filename> |
|
| 66 | +git add -p <filename> |
|
| 67 | +``` |
|
| 68 | + |
|
| 69 | +options: |
|
| 70 | + * `y` stage this hunk for the next commit |
|
| 71 | + * `n` do not stage this hunk for the next commit |
|
| 72 | + * `q` quit; do not stage this hunk or any of the remaining hunks |
|
| 73 | + * `a` stage this hunk and all later hunks in the file |
|
| 74 | + * `d` do not stage this hunk or any of the later hunks in the file |
|
| 75 | + * `g` select a hunk to go to |
|
| 76 | + * `/` search for a hunk matching the given regex |
|
| 77 | + * `j` leave this hunk undecided, see next undecided hunk |
|
| 78 | + * `J` leave this hunk undecided, see next hunk |
|
| 79 | + * `k` leave this hunk undecided, see previous undecided hunk |
|
| 80 | + * `K` leave this hunk undecided, see previous hunk |
|
| 81 | + * `s` split the current hunk into smaller hunks |
|
| 82 | + * `e` manually edit the current hunk |
|
| 83 | + * You can then edit the hunk manually by replacing `+`/`-` by `#` |
|
| 84 | + * `?` print hunk help |
|
| 85 | + |
|
| 56 | 86 | stash |
| 57 | 87 | ``` |
| 58 | 88 | git stash |