thiagowfx's avatar

Β¬ just serendipity πŸ€ (not just serendipity)

git reset --hard including submodules

β€’ 337 words β€’ 2 min β€’ updated

⚠️ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.

Problem statement: Whenever I open Rancher Desktop it insists on modifying my shell rc files. Make it stop!

bash:

diff
# diff --git bash/.bash_profile bash/.bash_profile
index c3962b2..89f475b 100644
--- bash/.bash_profile
+++ bash/.bash_profile
@@ -7,3 +7,7 @@
 #
 # The following line sources .bashrc and is recommended by http://mywiki.wooledge.org/DotFiles
 [ -r ~/.bashrc ] && . ~/.bashrc
+
+### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
+export PATH="/Users/thiago.perrotta/.rd/bin:$PATH"
+### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)
diff --git bash/.bashrc bash/.bashrc
index 7074bca..9ca8ffa 100644
--- bash/.bashrc
+++ bash/.bashrc
@@ -61,3 +61,7 @@ src_files "/etc/bash_completion"
 # Load user scripts and functions if existing. Order is important.
 # Corp config is handled as part of .bashrc.d.
 src_files "$HOME/.profile.d" "$HOME/.bashrc.d"
+
+### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
+export PATH="/Users/thiago.perrotta/.rd/bin:$PATH"
+### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)

zsh:

diff
diff --git etc/zsh/zshrc etc/zsh/zshrc
index efe5f79..02e0539 100644
--- etc/zsh/zshrc
+++ etc/zsh/zshrc
@@ -3959,3 +3959,7 @@ unfunction grml_status_feature
 # Local variables:
 # mode: sh
 # End:
+
+### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
+export PATH="/Users/thiago.perrotta/.rd/bin:$PATH"
+### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)

You could say it’s well-intentioned, but I think it’s rude to change the developer’s rc files without telling them so, and without providing an opt-out mechanism1.

Thus I wanted to revert their changes whenever I was done using Rancher Desktop. This worked:

shell
cd ~/.dotfiles && git reset --hard
cd vendor/grml-etc-core && git reset --hard

The second git reset --hard is needed because I employ a submodule for my zsh config.

However, after doing this many times in a row, it became tedious. And somehow I have the urge to improve this workflow…

Don't forget the time you spend finding the chart to look up what you save. And the time spent reading this reminder about the time spent. And the time trying to figure out if either of those actually make sense. Remember, every second counts toward your life total, including these right now.

XKCD Courtesy of Randall Munroe

Then I found out it’s possible to do it with an one-shot command, via:

shell
% git reset --hard --recurse-submodules

I knew of --recurse-submodules for git clone, but it never occurred to me it would also exist for git reset.


  1. I ended up finding an opt-out mechanism, which isn’t very intuitive to self-discover: rancher-sandbox/rancher-desktop#7315↩︎