git pull says “Untracked working tree file … would be overwritten by merge.

I’m trying to get my client back to some reasonable state, and I just can’t do it.

What I know:

  • I have (had?) some very minimal changes to a couple of local files.
  • Another user had added several new files and directories
  • I just want to “git pull” in the other user’s changes, and merge them with my locally edited files.
  • I have comitted my locally edited files, but not yet done “git push” because I don’t want those edits back on the origin/master.

When I run git pull, it says:

$ git pull
error: Untracked working tree file 'auth/__init__.py' would be overwritten by merge.
fatal: merging of trees 0e6c93c1d03a08c1f8b14cf76096979064112349 and beb9642a3abc785ccaab06c4b266e830b6389847 failed
Merge with strategy recursive failed.

What am I supposed to do now?  I’m tempted to just nuke this whole repository and start over, since my changes are so minimal, but I’m determined to understand & figure out git so that I don’t have to go through this nonsense every time.

$ git status 
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 2 and 9 different commit(s) each, respectively.
[...]

What does this mean? Does this mean that I have 2 commits, and that origin/master has 9?  How do I merge these commits in together?  Do I have to manually “git log” them and then “git merge”?  Argh!

GIT HAS THE WORST ERROR MESSAGES OF ANY PROGRAM I’VE EVER SEEN!

7 thoughts on “git pull says “Untracked working tree file … would be overwritten by merge.”

  1. NOTE: I am not what i call a git expert, I just use it for all my source control on a daily basis. My advice may not be considered best practice..

    Git is not bad if you understand the motivation. Wheres other tools will overwrite git refuses to “delete” changes without you expressly telling it too.

    The message is telling you that one copy has 2 commits since they where the same and the other copy has 9 different commits.

    some of these commits have deleted files or something like that –so there are untracked files that one copy is in fact tracking. Git will *not* touch a untracked anything unless explicitly told too.

    One way to get into this situation is by switching branches that changes the .git-ignore file. It seems unintuitive at first, but makes sense if you think out what else it should do. I for one do not want it to touch anything untracked without requiring some kind of force switch.

    So how to fix it?

    git-clean -n -d .

    this will do a dry run, and show all the untracked files that it will delete. Make sure you understand the differences between both copy’s you are tiring to merge before ruining this properly. Check the git-clean manpage for more options.

    After that you should be able to merge with the normal conflict resolution procedures I assume you know well.

  2. hi there
    im using bt5r3 i used to update weekly so when i did this order
    cd /pentest/exploits/set/ ; ./set-update
    it said
    cd /pentest/exploits/set/ ; ./set-update
    [-] Updating the Social-Engineer Toolkit, be patient…
    remote: Counting objects: 3521, done.
    remote: Compressing objects: 100% (990/990), done.
    remote: Total 3398 (delta 2448), reused 3357 (delta 2408)
    Receiving objects: 100% (3398/3398), 2.12 MiB | 169 KiB/s, done.
    Resolving deltas: 100% (2448/2448), completed with 100 local objects.
    From https://github.com/trustedsec/social-engineer-toolkit
    25062b5..91c4519 master -> origin/master
    From https://github.com/trustedsec/social-engineer-toolkit
    * [new tag] 4.7 -> 4.7
    * [new tag] 4.7.1 -> 4.7.1
    Updating a3a69e7..91c4519
    error: Untracked working tree file ‘config/set_config.py’ would be overwritten by merge. Aborting
    [*] The updating has finished, returning to main menu..

Leave a Reply