Over the weekend, I created a generic file.
Later I saw that the common functions that I was placing in that file will only be used for a specific use case.
Let us go rename the file.
Git Rename File
To rename a file we will use “git mv”.
git mv [filename-current] [filename-target]
rem rename file echo rename file "utility.ps1" to "utilityFile.ps1" git mv "utility.ps1" "utilityFile.ps1"
Check File Existence
If current file exists and target file does not exist, then it is OK to rename the file.
IF EXIST "utility.ps1" ( IF NOT EXIST "utilityFile.ps1" ( rem rename file echo rename file "utility.ps1" to "utilityFile.ps1" git mv "utility.ps1" "utilityFile.ps1" ) )
Let us do a quick status check.
Output – Image
Output – Text
>git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) renamed: utility.ps1 -> utilityFile.ps1
File is being renamed from utility.ps1 to utilityFile.ps1.