git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git switch --force vs --discard-changes: docs don't match behavior
@ 2025-03-17 16:50 David Mandelberg
  2025-03-17 17:19 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: David Mandelberg @ 2025-03-17 16:50 UTC (permalink / raw)
  To: git

Hi,

https://github.com/git/git/blob/683c54c999c301c2cd6f715c411407c413b1d84e/Documentation/git-switch.adoc?plain=1#L115-L124 
describes --force as "An alias for `--discard-changes`."

At least on git 2.47.2 though[1], it looks like --force will force more 
things than --discard-changes:

$ touch Makefile
$ git switch master
error: The following untracked working tree files would be overwritten 
by checkout:
         Makefile
Please move or remove them before you switch branches.
Aborting
$ git switch --discard-changes master
error: Untracked working tree file 'Makefile' would be overwritten by merge.
$ git switch --force master
branch 'master' set up to track 'origin/master'.
Switched to a new branch 'master'

Is this a bug in the code or documentation?

[1] I searched the mailing list to see if there were any relevant 
changes since then.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-17 18:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17 16:50 git switch --force vs --discard-changes: docs don't match behavior David Mandelberg
2025-03-17 17:19 ` Junio C Hamano
2025-03-17 17:39   ` Junio C Hamano
2025-03-17 18:13   ` David Mandelberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).