Session 2
Ingmar Steiner
2017-05-03
|
|
|
diff --side-by-side uk.txt us.txt
red <
green green
white white
grey | gray
black black
> blue
We refer to the difference between to files as a diff.
diff uk.txt us.txt
1d0
< red
4c3
< grey
---
> gray
5a5
> blueDiff “hunks” without context
diff -u uk.txt us.txt
--- uk.txt 2017-04-30 10:27:16.000000000 +0200
+++ us.txt 2017-04-30 10:27:45.000000000 +0200
@@ -1,5 +1,5 @@
-red
green
white
-grey
+gray
black
+blueDiff hunks with context, filenames
Diffs are patches
foo.txt
foo
baz
foo_v2.txt
foo
bar
baz
foo_v3.txt
foo
bar
baz
qux
foo_v4.txt
foo
bar
baz
quux
diff foo.txt foo_v2.txt > foo_v2.diff
1a2
> bardiff foo_v2.txt foo_v3.txt > foo_v3.diff
3a4
> quxdiff foo_v3.txt foo_v4.txt > foo_v4.diff
4c4
< qux
---
> quux
Kevin discovers a typo:
Some of us will be scouting with the flyers. Well be in radio contact with you.
and corrects it to:
Some of us will be scouting with the flyers. We’ll be in radio contact with you.
He emails the corrected file back to Bob.
Meanwhile, Stuart discovers a different typo:
“Well crush them now.”
He corrects it to:
“We’ll crush them now.”
He emails his corrected file back to Bob as well.
_emphasized_)perl -i -pe 's/_(.+?)_/$1/g' pg17958.txt and spends hours editing the text manually.
filehttp and httpssvn and svn+sshsvn:date, svn:author, svn:log (for commit messages), svn:executable, svn:eol-style, svn:mime-typesvn:ignore to avoid accidental versioning and cluttersvn:externalbzr uncommit, bzr revert, etc.hg rollback, hg backout, etc.git reset, git commit --amend, git revert, etc.--- lipsum.txt 2017-05-01 21:36:19.000000000 +0200
+++ lipsum2.txt 2017-05-01 21:36:14.000000000 +0200
@@ -1,6 +1,6 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
-do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-Ut enim ad minim veniam, quis nostrud exercitation ullamco
-laboris nisi ut aliquip ex ea commodo consequat. Duis aute
-irure dolor in reprehenderit in voluptate velit esse cillum
-dolore eu fugiat nulla pariatur.
+Lorem ipsum dolor sit amet, divide et impera, consectetur
+adipiscing elit, sed do eiusmod tempor incididunt ut labore et
+dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
+exercitation ullamco laboris nisi ut aliquip ex ea commodo
+consequat. Duis aute irure dolor in reprehenderit in voluptate
+velit esse cillum dolore eu fugiat nulla pariatur.→ No hard-wrapping; one sentence, one line
→ Manage EOL encoding systematically
.gitattributes files
.hgeol files
svn:eol-style properties
→ Use alternate strategies to manage large files
git-annex, etc.
Even better, manage large binary files at a higher level
→ Use a GUI (in addition to the command line)
→ Improve clarity for past commits and collaboration; easier cherry-picking
→ Tests on hosted or local CI platforms can be triggered automatically via “hooks”
→ Inspect local commits, and practice how to modify them to fix errors
→ Play around locally until everything works, but if you’ve shared commits with others, make sure you don’t cause confusion by changing that shared history
→ Configure SCM to use a merge tool for conflict resolution
Nesting external repositories
svn:externals
Extracting subdirectories (with history)
→ Elegant solution for certain scenarios, but adds complexity – use with caution!
…using any distributed SCM (except Git)