Should work on OS X and Linux, untested on Windows.
For the prompt and to avoid writing git
in front of every command.
- Clone https://github.com/krlmlr/git-sh
- Run
make
in this directory - One of:
- Run
mkdir -p ~/bin; ln -s ${PWD}/git-sh ~/bin/git-sh
in this directory - Run
sudo make install
in this directory
- Run
For the shortcuts covered here: s
, d
, a
, co
, ...
Paste the contents of config.sh
into your terminal, or run:
curl https://raw.githubusercontent.com/krlmlr/git-sh-workshop/master/config.sh | sh
- https://rstudio.cloud/project/143049
- Make sure to click "Save as copy" (red icon top right)
Restart all exercises with:
git checkout .
git clean -fd
git reset --hard origin/master
-
Run
script.R
. What does it show?- Ctrl + Shift + Enter or Cmd + Shift + Enter
-
Switch to the terminal, start
git sh
- Alt + Shift + R,
git sh
- Alt + Shift + R,
-
Make sure that you have a clean working copy.
s
-
Add a
show_blue()
function, and a call to that function inscript.R
. Inspect the changes.d
-
Commit both changes as an atomic unit.
aa
,s
,dc
cim
-
Add a comment to your code. Commit without changing the commit message.
ciao
-
Take a look at the log.
l
,lp
-
Start implementing a
show_pink()
function, then throw it away.coa
-
Create a new file, save it, then throw it away.
clean -n
,clean -f
-
Create a new file in a new directory, then throw it away.
clean -nd
,clean -fd
-
Create a new file. What does the status look like?
a
-
Remove this file. What does the status look like?
rm
-
Reset to the previous commit. Check the status.
qhp
-
Reset to the previous commit once more. Check the status.
qhp
-
Add a
show_yellow()
function at the top, and ashow_cyan()
function to the bottom offunctions.R
, and calls toscript.R
. Commit these changes as atomic units, edit the commit message (and perhaps the patch) invi
.ap
,ci
-
Amend the commit message.
cia
-
Take a look at the detailed log. Scroll and search.
lp
, cursor keys,/
-
Look up help for the
checkout
command. What did the-p
switch do again?git help ...
-
Create a branch
f-magenta
, implement ashow_magenta()
function and a call to that function. List your branches.cob
,b
-
Adapt
show_cyan()
to callglue(inverse(cyan(...)))
instead ofglue(cyan(...))
. Commit. Because you wanted to do it on a newf-cyan-inverse
branch (instead off-magenta
), you need to switch retroactively.b <branch>
,q --hard
,co <branch>
-
Create a branch
f-cyan-underline
frommaster
, adaptshow_cyan()
to callglue(underline(cyan(...)))
instead ofglue(cyan(...))
.cob <branch> master
-
Visualize all branches.
la
-
Merge
f-magenta
intomaster
.co
,m
-
Merge
f-cyan-inverse
intomaster
without editing the commit message.mo
-
List the merges without the details of the individual branches.
lf
-
Visualize the differences from each merge.
lfp
-
Delete the branches that you have merged successfully. Try deleting the
f-cyan-underline
branch.bm
,b -d
-
Restore the branches that you just deleted.
b <branch> <ref>
-
Try merging
f-cyan-underline
intomaster
. Abort the merge.mo
,ma
-
Switch to new a backup of the
f-cyan-underline
branch.cob
-
Try merging
master
into the new branch. Inspect.co
,mo
,s
,dc
,conflicts
,do
,dt
-
Resolve the conflict by combining the changes from the conflicting branches in
script.R
. Do not add or commit yet -- inspect beforehand. Make sure no conflict markers like<<<<<<<
remain in the file.s
,d
-
Commit using the default message.
cio
-
Switch to new a backup of the
f-cyan-underline
branch.cob
-
Try merging
master
into the new branch. Inspect. How did Git resolve the conflict?co
,mo
,s
,dc
,conflicts
,do
,dt
-
Switch to new a backup of the
f-cyan-underline
branch.cob
-
Try merging
master
into the new branch, keeping the changes of the new branch. Inspect.mo -X ours
-
Switch to new a backup of the
f-cyan-underline
branch.cob
-
Try merging
master
into the new branch, keeping the changes ofmaster
. Inspect.mo -X theirs
-
Switch to
master
, try merging the originalf-cyan-underline
branch. What happens?co
,mo
-
Abort the merge. Merge one of the branches where you successfully resolved the conflict into
master
. Explain.ma
,mo
,la
-
Check out the
f-magenta
branch again. What happens?co
-
Check out the parent of the
f-magenta
branch. What happens?co
,l
-
Use the log to find the SHA of an interesting commit, check it out. Explain.
l
,co
-
Switch to
master
, compare with thef-magenta
branch.d <ref>
-
Compare the
f-cyan-inverse
andf-cyan-underline
branches.d <ref>..<ref>
-
What's new in
f-cyan-inverse
, compared tof-cyan-underline
?d <ref>...<ref>
-
Branch off of an earlier revision of
master
that don't includef-magenta
andf-cyan-***
yet.l
,cob <branch> <ref>
-
Rebase
f-magenta
onto the new branch. Explain.co
,r <branch>
-
Move the new branch. Reset the tip of the new branch to the rebased
f-magenta
.co
,reset <branch>
-
Rebase
f-cyan-inverse
onto the new branch. Explain.co
,r <branch>
-
Move the new branch. Reset the tip of the new branch to the rebased
f-cyan-inverse
.co
,reset <branch>
-
Rebase
f-cyan-underline
onto the new branch. Explain.co
,r <branch>
-
Abort the rebase. Explain.
ra
-
Rebase
f-cyan-underline
onto the new branch, again.r <branch>
-
Resolve the conflict, continue the rebase.
rc
-
Move the new branch. Reset the tip of the new branch to the rebased
f-cyan-underline
.co
,reset <branch>
-
Inspect the log. How is it different from the merging exercise?
l
Task: Find the commit that introduced that magenta output function.
-
Set
master
as "bad" revision, agree to start bisection.bisect bad <branch>
-
Find an earlier revision of
master
that don't includef-magenta
yet. Set that earlier revision as "good".l
,bisect good <ref>
-
Do not look at the code. Run
script.R
to check if there is magenta output. If yes, it's a "bad" revision, otherwise a "good" one.bisect bad
,bisect good
-
Rinse and repeat, until you find your bad commit. Double-check that this is indeed the change that introduces magenta output.
show <ref>
-
Finish bisection.
bisect reset
-
Push/pull
-
More than one remote
-
Cherry-pick, revert, multiple cherry-pick