Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git .BACKUP .BASE .LOCAL .REMOTE files

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.

like image 872
magenta placenta Avatar asked Dec 26 '12 18:12

magenta placenta


2 Answers

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.

like image 191
Phlucious Avatar answered Nov 14 '22 08:11

Phlucious


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.

like image 26
Jhonatan Bianchi Avatar answered Nov 14 '22 06:11

Jhonatan Bianchi