0

I just setup my new git repo with p4merge setup as my external git mergetool. I'm on Mac and I just followed the git tutorial for external mergetools:

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

I worked through my merge conflicts, and I noticed it seemed to be keeping a separate instance of p4merge open for each new class conflict I opened up. In my old repo I would just hit save, close the window and git would automatically open up the next conflict (I was also on Windows at the time). Now doing so seemed to only result in the save persisting half the time, and I was having to keep entering 'git mergetool' into the terminal to get back into p4merge. After I got everything done my branch was clean but I had all these separate processes for p4merge still open. Closing them all out threw a bunch of errors in the command line and then I ended up with a TON of base/local/remote artifacts. Now the status of my branch looks something like this:

modified:   src/main/java/com/utils/ClientResponseUtils.java.orig
    deleted:    src/main/java/com/utils/ClientResponseUtils_BACKUP_70929.java
    deleted:    src/main/java/com/utils/ClientResponseUtils_BASE_70929.java
    deleted:    src/main/java/com/utils/ClientResponseUtils_LOCAL_70929.java
    deleted:    src/main/java/com/utils/ClientResponseUtils_REMOTE_70929.java
    modified:   src/main/java/com/utils/ListUtils.java.orig
    deleted:    src/main/java/com/utils/ListUtils_BACKUP_85524.java
    deleted:    src/main/java/com/utils/ListUtils_BASE_85524.java
    deleted:    src/main/java/com/utils/ListUtils_LOCAL_85524.java
    deleted:    src/main/java/com/utils/ListUtils_REMOTE_85524.java

Except MUCH, MUCH longer, it basically has a set of these for everything that I touched, and that was a lot of classes in the merge.

How do I go through this quickly without having to rm each one individually, and how do I prevent this from happening again in the future?

Looking a little further before posting, I realize this support page might help me clean up my command line usage:

http://answers.perforce.com/articles/KB/2848/

But I'm still wondering the best way to clean up such a horrible and lengthy mess, and why it happened in the first place.

torek
  • 448,244
  • 59
  • 642
  • 775
Benny
  • 242
  • 1
  • 5
  • 17
  • 1
    I don't use p4merge (or `git mergetool` in the first place) so don't have advice on how *to* use it, but all those temporary files named `*_BACKUP_*`, `*_BASE_*`, etc., are ones that `git mergetool` itself creates. They should not show up as "deleted", not because they aren't, but because they should never have been committed in the first place. To show up as "deleted" someone must have added and committed them, presumably by mistake. – torek Jun 05 '17 at 22:02
  • They showed up under my git status after I had manually closed down all the p4merge instances I thought I was done with. I clearly have a couple problems on my hand: how to use p4merge correctly on Mac, and getting rid of all these extra files now. – Benny Jun 05 '17 at 22:06

1 Answers1

2

This will help

git config --global mergetool.keepBackup false

If you are mainly concerned with not committing the files, you can add them to .gitignore:

*_BACKUP_*
*_BASE_*
*_LOCAL_*
*_REMOTE_*

And you can occasionally run git clean -fx to remove them all

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
  • Thanks for all of these, which have all been added to my Git-Fu repository. I also realized in the process of cleaning this up that my permissions were screwed up (I did some branch work while under root on my machine, I think that's where I initially went wrong). I fixed this by going to .git/objects and running sudo chown -R myname:'mygroup' * Basically adding this comment for my own edification incase this happens to me again in two months and I have to remember what I did the last time. – Benny Jun 06 '17 at 14:43