Skip to main content

4 posts tagged with "git"

View All Tags

Understanding `@@ -1,2 +3,4 @@` part of the Git diff

diff -u <(seq 16) <(seq 16 | grep -Ev '^(2|3|14|15)$')
--- /dev/fd/11 2019-09-26 15:48:31.000000000 -0500
+++ /dev/fd/12 2019-09-26 15:48:31.000000000 -0500
@@ -1,6 +1,4 @@
1
-2
-3
4
5
6
@@ -11,6 +9,4 @@
11
12
13
-14
-15
16
  • -1,6 means that this piece of the first file starts at line 1 and shows a total of 6 lines; therefore it shows lines 1 to 6 (- means "old", as we usually invoke it as diff -u old new)
  • +1,4 means that this piece of the second file starts at line 1 and shows a total of 4 lines; therefore it shows lines 1 to 4 (+ means "new")
  • @@ -11,6 +9,4 @@ for the second hunk is analogous: in the old file, we have 6 lines, starting at line 11 of the old file; in the new file, we have 4 lines, starting at line 9 of the new file

This is for anyone who still didn't quite understand. In @@ -1,6 +1,4 @@ pls don't read -1 as "minus one" or +1 as "plus one". Instead read this as "line 1 to 6" in old (first) file. Note here - implies "old" not minus.

Source: https://stackoverflow.com/a/31615438/3135248

Gitignore

# Empty lines are being ignored.
# Trailing spaces are ignored unless they are quoted with backslash ("\").

\#not_a_comment.xyz
!\#not_a_comment.xyz

# If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself.
# Otherwise the pattern may also match at any level below the .gitignore level.

directory_only/
directory_or_file

# An asterisk "*" matches anything except a slash.
# The character "?" matches any one character except "/".
# The range notation, e.g. [a-zA-Z], can be used to match one of the characters in a range.

# Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
**/foo # match in all directories
abc/** # matches all files inside directory "abc"
a/**/b # zero or more directories ("a/b", "a/x/b", "a/x/y/b", ...)

https://git-scm.com/docs/gitignore