24

We're getting git installed here at work for a project and I'm playing around with it with another co-worker.

I've been resolving some choreographed merge conflicts but I'm ending up with a bunch of extra files I don't want. They are .BACKUP .BASE, .LOCAL and .REMOTE files. Based on those names, they seem to be coming from resolving my merges. Some exact file names I'm getting are:

  • index.shtml.BACKUP.16908.shtml
  • index.shtml.BASE.16908.shtml
  • index.shtml.LOCAL.16908.shtml
  • index.shtml.REMOTE.16908.shtml
  • I also have another set of the files above but ending in .21384, assuming from another merge attempt

Is it possible to not save these files? As you can imagine, it's kind of annoying to now have 9 versions of index.shtml. I'm using git's built-in merge tool, tortoisemerge.

I ran into something similar by running git log, it apparently created a "df" file. That was easy enough to deal with by just including it in a .gitignore file. I don't want to just accumulate files like above throughout the project, though.

4
  • 2
    This is probably something specific to tortoisemerge. Tortoisemerge is not part of the standard Git distribution. Dec 26, 2012 at 18:45
  • So git must have recognized that I have tortoise installed and included tortoisemerge as an option when I run git mergetool? Dec 26, 2012 at 19:14
  • 1
    Note that git clean -i will interactively lead you thru deleting these files. But beware, it will also offer to delete any other files that are not ("yet") under version control.
    – nealmcb
    Sep 27, 2019 at 16:01
  • @GregHewgill Maybe this has changed (?), because I see these files created when I do just a vanilla git merge.
    – 1252748
    Oct 21, 2020 at 13:49

3 Answers 3

27

As the other answer mentions, these files seem to be created by Git's merge tool when resolving conflicts. The default Git settings leave these extra files behind, even after the conflict is resolved, but current versions of Git allow you to set a config variable to cause Git to always delete these temporary files after finishing the merge.

You can do this in Git Bash with the command...

git config --global mergetool.keepBackup false

The --global argument is optional, of course, and controls whether this setting is local to this user (global) or the current repository.

More info here.


Edit: Even with this setting enabled, these files can also accumulate and persist if your repo ends up in an unresolved state during a MERGE that you attempt to fix by aborting with a hard reset.

For example, this happened to me several times using certain configurations of Qt Creator 4.7.x until I realized what was happening and correctly configured Git's mergetool on my machine.


Note: I had a similar question and ended up here. Although the current answer eventually led me to the correct solution, I didn't feel that it answered the question and an updated answer was in order.

3

In Tortoise, go to setting and uncheck "Backup original file" (one time operation) Next time you open it you can do a regular merge, Tortoise will create .base, .backup, .local, .remote, but when you save the merge Tortoise will automatically remove this files.

1
  • Note that this only applies to Tortoise and not git in general.
    – Jeremy
    Dec 7, 2016 at 15:00
-3

To delete the untracked files and directories, type:

git clean -df
1
  • 2
    Just to emphasize, this deletes all untracked files and directories, not just those temporary files created during the merge process.
    – 1252748
    Oct 21, 2020 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.