$ ./guess_the_languageGit
Git · medium · #10

Which sequence lets you switch while keeping your edits for later?

$ git switch other
error: Your local changes to the following files would be overwritten by checkout:
	config.ini
Please commit your changes or stash them before you switch branches.
  1. git restore config.ini, then switch
  2. git branch -f other HEAD
  3. git switch --detach other
  4. git stash, then git switch other
Stashing saves the edits and cleans the working tree so the switch can proceed; git stash pop brings them back. Restoring the file would throw the edits away.
Play Git ▸