0

MAC produced an README.~md file When I have solved the git conflict use the command git mergetool with Beyond Compare. I think two ways to solve this, but I don't know which is the best practice.

  1. What can I do to avoid produce the .~ file?
  2. I add the *.~** into the .gitignore,and delete the *.~** file later.

I found the README.~md show the detail of this conflict. It contains the unsolved conflict content.

jiexishede
  • 2,473
  • 6
  • 38
  • 54
  • You could try disabling [`mergetool.keepBackup`](https://git-scm.com/docs/git-config) but that should actually create `.orig` files, not something with a tilde, so I’m not sure if that’s actually a backup file by Git or not. – poke Jan 19 '17 at 10:24
  • There are no `.orig` file in a current folder. Only `README.md` and `README.~md`. – jiexishede Jan 19 '17 at 11:16

2 Answers2

0

Probably the best option is to just add these files pattern to the .gitignore file (you never know when this file may be helpful in the future).

If you want to automatically get rid of these files, you may create a hook which removes them when they're not useful anymore (e.g. after execute a commit), something like this shall do the trick:

#!/usr/bin/env python

import os, re


print("Deleting all '*.~*' files in working directory")
auxfile_pattern = re.compile('.+\.~\w+$')
for root, dirs, files in os.walk('.'):
    for filename in files:
        if auxfile_pattern.search(filename):
            os.unlink(os.path.join(root, filename))
Álvaro P.
  • 1,031
  • 9
  • 9
0

enter image description here

Beyond Compare set the Backups all backups to disable. By the way, Beyond Compare is a good tool.

jiexishede
  • 2,473
  • 6
  • 38
  • 54