How do i rename a file in a git repository?



  • Here we want to rename the lastorders.php file to lastdrinks.php

    $ ls
    lastorders.php  NewUser.txt  README.md  Test.php
    

    Use the git move command to rename the file.

    $ git mv lastorders.php lastdrinks.php
    

    The status shows as "renamed"

    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
    	renamed:    lastorders.php -> lastdrinks.php
    

    The commit show file as rename

    $ git commit -m "renamed lastorders.php to lastdrinks.php"
    [master 289adb5] renamed lastorders.php to lastdrinks.php
     1 file changed, 0 insertions(+), 0 deletions(-)
     rename lastorders.php => lastdrinks.php (100%)
    

Log in to reply
 

© Lightnetics 2024