Background
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
Git Rename File
To rename a file we will use “git mv”.
Git MV
Syntax
git mv [filename-current] [filename-target]
Sample
Rename File
Outline
Rename File.
Script
rem rename file echo rename file "utility.ps1" to "utilityFile.ps1" git mv "utility.ps1" "utilityFile.ps1"
Check File Existence
Outline
If current file exists and target file does not exist, then it is OK to rename the file.
Script
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" ) )
Git Status
Let us do a quick status check.
Git Status
Syntax
git status
Sample
git status
Output
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
Explanation
File is being renamed from utility.ps1 to utilityFile.ps1.