Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider replacing "checkout" with "switch" and "restore", if widely available in the future #691

twitwi opened this issue Sep 17, 2019 · 2 comments


Copy link

commented Sep 17, 2019

git checkout has been confusing for learners (especially when they later discover branching), see #169 for a first episode of this discussion.

This summer 2019, git started an experimental feature to solve this issue replacing it with two commands git restore and git switch

I though this was interesting to share, if people want to try the feature and/or push for its adoptions and/or start thinking about how the lessons might need to be modified.



This comment has been minimized.

Copy link

commented Sep 24, 2019

Was about to open an issue on this (currently helping during a git session), seems worth considering.


This comment has been minimized.

Copy link

commented Oct 14, 2019

I agree, the new switch and restore commands clearly separate two different tasks into separate commands and will reduce cognitive load on students. I am now using these new commands regularly in my daily work.

However, it will be some time before git 2.23 is generally available to Carpentries workshop students. The workshop template suggests downloading the latest version (currently 2.23) of git on Windows and Mac from the web, and on Linux via their OS's package manager. Ubuntu 18.04 LTS is one popular distribution of Linux which only includes git 2.17. Hopefully, the next LTS release of Ubuntu (20.04 - April 2020) will include git 2.23 or newer, but it may be some time after that before typical Linux systems used by Carpentries students have 2.23 or newer available. Does the Carpentries survey what linux distros students utilize? That information could be helpful in making the decision when to update this content.

I do not plan to submit a PR at this time as it is too early to make the change. Here are the places in the lessons that can be changed once git >=2.23 is generally available.

  • - use git restore throughout. Additionally, the warning section "Don’t Lose Your HEAD" can be removed as git restore now only restores files. Even git switch <hash> would not result in this behavior, users need to explicitly opt-in to a detached HEAD with git switch --detach <hash>
  • - Remove the reference to git checkout ID. The proper command would be git switch --detach <hash> which has not been taught in prior lessons.
  • - The solution to "Conflicts on Non-textual files" should use git restore instead of git checkout.

The lesson does not teach branching, so git switch is not needed at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.