How do I commit case-sensitive only filename changes in Git?

前端 未结 16 2308
我在风中等你
我在风中等你 2020-11-22 03:31

I have changed a few files name by de-capitalize the first letter, as in Name.jpg to name.jpg. Git does not recognize this changes and I had to de

相关标签:
16条回答
  • 2020-11-22 04:08

    I used those following steps:

    git rm -r --cached .
    git add --all .
    git commit -a -m "Versioning untracked files"
    git push origin master
    

    For me is a simple solution

    0 讨论(0)
  • 2020-11-22 04:08

    I took @CBarr answer and wrote a Python 3 Script to do it with a list of files:

    #!/usr/bin/env python3
    # -*- coding: UTF-8 -*-
    
    import os
    import shlex
    import subprocess
    
    def run_command(absolute_path, command_name):
        print( "Running", command_name, absolute_path )
    
        command = shlex.split( command_name )
        command_line_interface = subprocess.Popen( 
              command, stdout=subprocess.PIPE, cwd=absolute_path )
    
        output = command_line_interface.communicate()[0]
        print( output )
    
        if command_line_interface.returncode != 0:
            raise RuntimeError( "A process exited with the error '%s'..." % ( 
                  command_line_interface.returncode ) )
    
    def main():
        FILENAMES_MAPPING = \
        [
            (r"F:\\SublimeText\\Data", r"README.MD", r"README.md"),
            (r"F:\\SublimeText\\Data\\Packages\\Alignment", r"readme.md", r"README.md"),
            (r"F:\\SublimeText\\Data\\Packages\\AmxxEditor", r"README.MD", r"README.md"),
        ]
    
        for absolute_path, oldname, newname in FILENAMES_MAPPING:
            run_command( absolute_path, "git mv '%s' '%s1'" % ( oldname, newname ) )
            run_command( absolute_path, "git add '%s1'" % ( newname ) )
            run_command( absolute_path, 
                 "git commit -m 'Normalized the \'%s\' with case-sensitive name'" % (
                  newname ) )
    
            run_command( absolute_path, "git mv '%s1' '%s'" % ( newname, newname ) )
            run_command( absolute_path, "git add '%s'" % ( newname ) )
            run_command( absolute_path, "git commit --amend --no-edit" )
    
    if __name__ == "__main__":
        main()
    
    0 讨论(0)
  • 2020-11-22 04:10

    If nothing worked use git rm filename to delete file from disk and add it back.

    0 讨论(0)
  • 2020-11-22 04:14

    We can use git mv command. Example below , if we renamed file abcDEF.js to abcdef.js then we can run the following command from terminal

    git mv -f .\abcDEF.js  .\abcdef.js
    
    0 讨论(0)
提交回复
热议问题