From da60eabff1d1ee3b81a5a1051dc5470200f33b80 Mon Sep 17 00:00:00 2001 From: kpetersn <kmpeters@anl.gov> Date: Thu, 2 Mar 2023 17:35:57 +0000 Subject: [PATCH] Added details for the example for how to avoid manually editing files --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca4f17c..f9921f1 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,60 @@ Both the xxx and motorVMC repos have a **solution** branch with tags for each st Note: the motorVMC module is only modified in section 4, so the only tags it has for later sections are 5.1 and 6.1. -### Example: how to avoid manually editing files +### How to avoid manually editing files + +**Example**: You've been following the instructions in the training until [step 5.7.2](https://git.aps.anl.gov/practical_beamline_controls_training/session_2/instructions/-/blob/main/5-Add-virtual-motors.md#572-modify-iocshvmccmd), which asks to you make a lot of change to **vmc.cmd**, but you'd rather not make those changes yourself. + +Do the following to see if there are any files you've modified/created manually: +``` +$ git status +``` + +If git reports any "Changes not staged for commit" or "Untracked files", do the following to save your work to a **working** branch: + +``` +$ git stash +$ git checkout -b working +$ git stash apply +$ git add ${IOC_DIR}/xxx +$ git commit -m "Backup of my work before switching to a tag on the solution branch" +``` + +At this point you can safely proceed to step 5.7.3 +``` +$ git checkout 5.7.3 +``` +<details> +<summary>output</summary> + +``` +Note: switching to '5.7.3'. + +You are in 'detached HEAD' state. You can look around, make experimental +changes and commit them, and you can discard any commits you make in this +state without impacting any branches by switching back to a branch. + +If you want to create a new branch to retain commits you create, you may +do so (now or later) by using -c with the switch command. Example: + + git switch -c <new-branch-name> + +Or undo this operation with: + + git switch - + +Turn off this advice by setting config variable advice.detachedHead to false + +HEAD is now at 8a0470c Modified iocsh/vmc.cmd +``` +</details> + +Git can also show you the changes that were made: + +``` +$ git show 5.7.3 +``` +Note: `git show <step_number>` is only useful if the previous step involved creating or modifying a file. ### Example: how to jump to a specific section -- GitLab