Function: magit-file-untrack

magit-file-untrack is an autoloaded, interactive and byte-compiled function defined in magit-files.el.

Signature

(magit-file-untrack FILES &optional FORCE)

Documentation

Untrack the selected FILES or one file read in the minibuffer.

With a prefix argument FORCE do so even when the files have staged as well as unstaged changes.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-files.el
;;;###autoload
(defun magit-file-untrack (files &optional force)
  "Untrack the selected FILES or one file read in the minibuffer.

With a prefix argument FORCE do so even when the files have
staged as well as unstaged changes."
  (interactive (list (or (if-let ((files (magit-region-values 'file t)))
                             (if (magit-file-tracked-p (car files))
                                 (magit-confirm-files 'untrack files "Untrack")
                               (user-error "Already untracked"))
                           (list (magit-read-tracked-file "Untrack file"))))
                     current-prefix-arg))
  (magit-with-toplevel
    (magit-run-git "rm" "--cached" (and force "--force") "--" files)))