Search code examples
gitgithubgit-push

Git adding duplicate files into the repo


I have this file called readme.html in my git Repo.

Its been there since 10 months, Have not touched it.

Today I worked with other files and did a git add --all, committed and pushed the new version.

The readme.html was not changed but I have this file called readme.4ead5bd97d0927ddb88f8f672067910a.html.

It has the same contents as readme.html.

How to deal with this and any idea why this happened ?


Solution

  • Some tool has generated it as a backup or for some other reasons.

    You can simply remove this file withe those commands:

    # remove and commit the file
    rm readme.4ead5bd97d0927ddb88f8f672067910a.html
    git rm --cached readme.4ead5bd97d0927ddb88f8f672067910a.html
    
    # just verify that  the file will be deleted
    git add -A .
    git status
    
    # commit the deletion of the file
    git commit -m "Deleted readme.4ead5bd97d0927ddb88f8f672067910a.html"
    
    git push origin <branch>