how to rename a file in git code example

Example 1: git rename file

$ git mv old_filename new_filename

Example 2: how to Rename or Move files in GIT

# Short answer:
git mv filename new_filename
or
git mv /path/to/file_location /path/to/new/file_location

# Note, if you manually move a file or rename it (w/o git mv) git may
# 	treat the moved/renamed file as a new file 
# Note, it's fairly popular to use the alias gm for git mv

Example 3: how to rename a file inside git bash

$ git clone [email protected]:username/reponame.git
$ cd reponame
$ git mv README README.md
$ git commit -m "renamed"
$ git push origin master

Example 4: rename file in git commit

> $ git mv css/iphone.css css/mobile.css
> $ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   renamed:    css/iphone.css -> css/mobile.css
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   index.html
#