Git clean - Cleaning the Git repository to be able to merge with remote

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:06

Sometimes you get Git messages like

The following untracked working tree files would be overwritten by checkout

 The following command can be helpful in that case.

git clean -d -fx ""


-x means ignored files are also removed as well as files unknown to git.
-d means remove untracked directories in addition to untracked files.
-f is required to force it to run.

 I've learned this by a discussion on Stackoverflow:

Another option

Another possibility is to execute the following command, to reset all changes which are outside of the stage:

git checkout — .

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.