But do not open them!
create_all_exercises(parent_path)
create_all_exercises(parent_path)
parent_path |
Path where to create the exercise repo |
The parent path
I notice a bug in my codebase.
I can see the bug was not there a bunch of commits ago.
Beside doing regular debugging, I can find out
which commit introduced the bug by using git bisect
.
See https://git-scm.com/docs/git-bisect and
https://www.jimhester.com/post/2019-04-24-git-bisect/.
exo_bisect(parent_path)
exo_bisect(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git bisect
.
parent_path <- withr::local_tempdir() path <- exo_bisect(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_bisect(parent_path = parent_path)
If debugging for instance created now useless untracked files and directories,
there's no need to remove them "manually".
The tool for that is git clean
:
git clean -n
for a dry run;
git clean -f
to run it;
Add -d
to also remove directories.
See https://git-scm.com/docs/git-clean.
exo_clean_dir(parent_path)
exo_clean_dir(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git clean
.
parent_path <- withr::local_tempdir() path <- exo_clean_dir(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_clean_dir(parent_path = parent_path)
To go with https://ohshitgit.com/#accidental-commit-master
exo_committed_to_main(parent_path)
exo_committed_to_main(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git reset --hard
, git branch
, git checkout
parent_path <- withr::local_tempdir() path <- exo_committed_to_main(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_committed_to_main(parent_path = parent_path)
To go with https://ohshitgit.com/#accidental-commit-wrong-branch
exo_committed_to_wrong(parent_path)
exo_committed_to_wrong(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git cherry-pick
, git reset
, git checkout
parent_path <- withr::local_tempdir() path <- exo_committed_to_wrong(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_committed_to_wrong(parent_path = parent_path)
I made some work in a feature branch and want to merge it. Meanwhile, the main branch advanced. Unfortunately someone touched the same file as I did. Now I need to fix a merge conflict!
See also https://happygitwithr.com/git-branches.html#dealing-with-conflicts.
exo_conflict(parent_path)
exo_conflict(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git merge
.
parent_path <- withr::local_tempdir() path <- exo_conflict(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_conflict(parent_path = parent_path)
To go with https://ohshitgit.com/#change-last-commit-message
exo_latest_message(parent_path)
exo_latest_message(parent_path)
parent_path |
Path where to create the exercise repo |
The path
git commit --amend
parent_path <- withr::local_tempdir() path <- exo_latest_message(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_latest_message(parent_path = parent_path)
To go with https://ohshitgit.com/#change-last-commit
exo_one_small_change(parent_path)
exo_one_small_change(parent_path)
parent_path |
Path where to create the exercise repo |
The path
git commit --amend --no-edit
parent_path <- withr::local_tempdir() path <- exo_one_small_change(parent_path = parent_path) # Now add "thing 3" to the "bla" file # And amend the latest commit
parent_path <- withr::local_tempdir() path <- exo_one_small_change(parent_path = parent_path) # Now add "thing 3" to the "bla" file # And amend the latest commit
I am working in a feature branch that's all my own.
I made many small commits as I was figuring things out.
Now I want the commits to tell a story for the PR reviewers,
and not a story of how many stupid mistakes I made!
The tool for that is git base --interactive
also available as git rebase -i
.
Useful links:
https://jvns.ca/blog/2023/11/06/rebasing-what-can-go-wrong-/
https://github.blog/2022-06-30-write-better-commits-build-better-projects/
exo_rebase_i(parent_path)
exo_rebase_i(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git rebase -i
parent_path <- withr::local_tempdir() path <- exo_rebase_i(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_rebase_i(parent_path = parent_path)
I am working in a feature branch that's all my own.
I made many small commits as I was figuring things out.
Now I want the commits to tell a story for the PR reviewers,
and not a story of how many stupid mistakes I made!
Instead of git base --interactive
also available as git rebase -i
.¡,
I can also use git reset --mixed
and then build the commits.
Useful links:
exo_reset(parent_path)
exo_reset(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git reset --mixed
parent_path <- withr::local_tempdir() path <- exo_reset(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_reset(parent_path = parent_path)
To go with https://ohshitgit.com/#undo-a-file
exo_revert_file(parent_path)
exo_revert_file(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git log
, git checkout
, git commit
parent_path <- withr::local_tempdir() path <- exo_revert_file(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_revert_file(parent_path = parent_path)
I made many edits to a file, in different places.
This is too much for a commit, since small commits are best practice.
I need to add the changes to Git bit by bit.
The tool for that is git add --patch
, also available as git add -p
.
If all your changes are presented to you as one chunk by git add --patch
,
choose the "s" option for splitting.
See https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging#_staging_patches.
Note that patch is also an option for git commit
, if you prefer so.
exo_split_changes(parent_path)
exo_split_changes(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git add --patch
, git add -p
.
parent_path <- withr::local_tempdir() path <- exo_split_changes(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_split_changes(parent_path = parent_path)
To go with https://ohshitgit.com/#magic-time-machine
exo_time_machine(parent_path)
exo_time_machine(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git reset
, git reflog
parent_path <- withr::local_tempdir() path <- exo_time_machine(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_time_machine(parent_path = parent_path)
To go with https://ohshitgit.com/#undo-a-commit
exo_undo_commit(parent_path)
exo_undo_commit(parent_path)
parent_path |
Path where to create the exercise repo |
The path to the new project
git log
, git revert
parent_path <- withr::local_tempdir() path <- exo_undo_commit(parent_path = parent_path)
parent_path <- withr::local_tempdir() path <- exo_undo_commit(parent_path = parent_path)