tags:

views:

192

answers:

3

In the "emacs-git" mode for emacs, is there a way to do a "checkout -f" or equivalent?

I've only recently started using emacs-git. I've liked it so far, until I tried to switch to another branch and got a message about an "untracked working tree file would be overwritten" and the checkout is aborted.

Previously when using git from the commandline I've always just done "git checkout -f " to switch branches, but I can't seem to find the equivalent of the "-f" switch in emacs-git.

Any ideas?

A: 

The git checkout -f command is a much more dangerous command than not using the -f flag, is this really what you want to do? You run the risk of accidentally discarding changes that have not yet been checked in anywhere.

The error you got relates to a file that is not tracked in your current branch (but the file exists on disk), but is tracked in the branch you're changing to. Git wants to overwrite the untracked file with the one from the new branch. What if there was something important in that file? The error message indicates that you should do something with that file first, before switching branches.

Greg Hewgill
It is what I want to do. File(s) in question are, like you said, ignored in the current branch (generated stuff). I honestly don't know if they're ignored or not in the branches I'm trying to switch to. For now I've already used git from the command line to checkout what I need, but I'm curious for future usage if there's a way to pass arguments like -f to git commands using emacs-git.
Bob McCormick
Ok, fair enough. I've never used emacs-git, so sorry I wasn't of more help.
Greg Hewgill
A: 

Several equivalent commands aren't present in these packages (I personally use magit myself). I'd suggest either using the command-line for these specific commands, or modifying the package you use.

Ramkumar Ramachandra
A: 

Not exactly what you are looking for but I have used ESC-! command in similar situations to quickly run a simple shell command in emacs.

Zitrax