Here’s how I just renamed a file under a git repository since I didn’t want to lose tracking changes by just deleting the old file and adding the new one to the repository. Although I use SmartGit but I had to do the renaming part on the terminal.
1. Rename the file using git command
$ git mv old_filename new_filename
2. Use git status to check the old and new file names.
$ git status # On branch your-branch # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # renamed: old_filename -> new_filename #
3. Commit the file using SmartGit or from terminal using
$ git commit -m "Rename file"
4. Push changes to the remote repository from SmartGit or from terminal using
$ git push