gitgithubgit-mv

Why do my local folder names differ from the remote repo folder names?


How is this even possible?

Here are my local folders (example)

/features
   /AS
   /auth
   /chargers
   /chargingHistory

And my remote folders. (They are the same branch)

/features
   /AS
   /Auth
   /Chargers
   /ChargingHistory

I made changes to my the folder name in another branch, I just don't understand how it can be affecting my current branch. And I have not pulled from the branch where folder name changes were made to the current branch. Because of this, it is causing a build error..

It is affecting all the other branches except for the one where actual changes were made :(

The remote branches are fine, it is just that it is causing unnecessary build errors and I would not be able to see the actual errors in the future

How can I fix this?


Solution

  • Git can be configured to be a case sensitive or not. Looks like on your case that git is configured not to be case sensitive

    TL;DR;

    # Change the case flag to false so that git will trach the changes
    git config core.ignorecase false
    

    Long Demo, and how how to fix it:

    #!/bin/bash
    
    # Clear any exsiting code
    rm -rf /tmp/remoteRepository
    rm -rf /tmp/localRepository
    
    ### Create the dummy repository
    git init --bare /tmp/remoteRepository
    
    ### Clone the repository
    git clone /tmp/remoteRepository /tmp/localRepository
    
    ### Switch to the new working directory
    cd /tmp/localRepository
    
    ###
    ### Setup the ignorecase flag for the repository
    ###
    git config core.ignorecase true
    
    ## Create come content
    mkdir -p AAA-folder
    echo 'text' > AAA-folder/AAA-file.txt
    
    ### Commit the changes
    git add AAA-folder/AAA-file.txt
    git commit -m "Added AAA-file.txt"
    
    ### Push the changes to the remote repository
    git push origin main
    
    ### Lets now change the folder name
    mv AAA-folder aaa-folder
    
    ## Let check the staging area for changes
    ##
    ## >>> No changes !!!
    git status
    
    ## List local files and directories
    echo "----------------------------------------------------"
    echo "Local files:"
    echo ""
    ls | grep *-folder
    
    ## List local files as they are "stored" in git
    echo "----------------------------------------------------"
    echo "Local git file names:"
    echo ""
    git ls-tree  main --name-only
    
    ## List remotes file and folders
    echo "----------------------------------------------------"
    echo "Remote files:"
    echo ""
    git ls-tree -r origin/main --name-only
    
    # Change the case flag to false so that git will trach the changes
    git config core.ignorecase false
    
    # Verify that now we see the changes
    echo "----------------------------------------------------"
    git status