From e6b12b75f71a195b803cd85e4f3cac8fcb33e199 Mon Sep 17 00:00:00 2001 From: blinry Date: Wed, 6 Jan 2021 13:10:32 +0100 Subject: [PATCH] Beginning of remotes chapter --- levels/remotes/add | 33 +++++++++++++++++++++++++++++++++ levels/remotes/fetch | 35 +++++++++++++++++++++++++++++++++++ levels/remotes/rename-delete | 23 +++++++++++++++++++++++ levels/remotes/sequence | 3 +++ levels/sequence | 1 + 5 files changed, 95 insertions(+) create mode 100644 levels/remotes/add create mode 100644 levels/remotes/fetch create mode 100644 levels/remotes/rename-delete create mode 100644 levels/remotes/sequence diff --git a/levels/remotes/add b/levels/remotes/add new file mode 100644 index 0000000..db24b7d --- /dev/null +++ b/levels/remotes/add @@ -0,0 +1,33 @@ +title = Adding a remote +cards = checkout + +[description] + +Let's work together with others! Your friend has their own repo at the URL `../friend` - you can add it using + + git remote add [name] [URL] + +where `[name]` is an arbitrary, short name you pick for the remote. + +When you've done that, you can get all commits from that remote using + + git pull friend + +There's a letter for you! + +[setup] + +git remote remove friend + +[setup friend] + +echo "I'm really committed to our friendship! <3" > love_letter +git add . +git commit -m "Write a letter" + +[win] + +# Add a remote that points to ../friend. +git remote -v | grep '../friend' +# Pull from the remote. +git show HEAD:love_letter | grep committed diff --git a/levels/remotes/fetch b/levels/remotes/fetch new file mode 100644 index 0000000..77f1c17 --- /dev/null +++ b/levels/remotes/fetch @@ -0,0 +1,35 @@ +title = Fetching from remotes +cards = checkout + +[description] + +Here, you already have two remotes configured! You can list them using `git remote`. + +Fetch from both, and look at the suggestions. + +Then, make a new commit on top of your original one that introduces a compromise. + +[setup] + +echo "The bikeshed should be ???" > proposal +git add . +git commit -m "What do you think?" + +[setup friend1] + +git pull yours main +echo "The bikeshed should be green" > proposal +git commit -am "Green" + +[setup friend2] + +git pull yours main +echo "The bikeshed should be blue" > proposal +git commit -am "Blue" + +[win] + +# Your proposal is acceptable for friend1. +git show main:proposal | git grep green +# Your proposal is acceptable for friend2. +git show main:proposal | git grep blue diff --git a/levels/remotes/rename-delete b/levels/remotes/rename-delete new file mode 100644 index 0000000..c026204 --- /dev/null +++ b/levels/remotes/rename-delete @@ -0,0 +1,23 @@ +title = Deleting and renaming a remote +cards = checkout + +[description] + +Here, you already have two remotes configured! You can list them using `git remote`. + +[setup] + +git remote rename friend frend + +[setup friend] + +[setup enemy] + +[win] + +# Rename the remote with the typo (using `git remote rename [old name] [new name]`) +git remote | grep friend +# The remote with the typo is gone. +! grep 'frend' <(git remote) +# Delete the remote you don't want to keep (using `git remote remove [remote]`) +! grep 'enemy' <(git remote) diff --git a/levels/remotes/sequence b/levels/remotes/sequence new file mode 100644 index 0000000..258c089 --- /dev/null +++ b/levels/remotes/sequence @@ -0,0 +1,3 @@ +add +rename-delete +fetch diff --git a/levels/sequence b/levels/sequence index 8d87994..df36100 100644 --- a/levels/sequence +++ b/levels/sequence @@ -1,5 +1,6 @@ stash index +remotes shit-happens time-machine low-level