github – Rename file with Git

github – Rename file with Git

As far as I can tell, GitHub does not provide shell access, so Im curious about how you managed to log in in the first place.

$ ssh -T git@github.com
Hi username! Youve successfully authenticated, but GitHub does not provide
shell access.

You have to clone your repository locally, make the change there, and push the change to GitHub.

$ git clone git@github.com:username/reponame.git
$ cd reponame
$ git mv README README.md
$ git commit -m renamed
$ git push origin master

Note that, from March 15th, 2013, you can move or rename a file directly from GitHub:

(you dont even need to clone that repo, git mv xx and git push back to GitHub!)

renaming

You can also move files to entirely new locations using just the filename field.
To navigate down into a folder, just type the name of the folder you want to move the file into followed by /.
The folder can be one that’s already part of your repository, or it can even be a brand-new folder that doesn’t exist yet!

moving

github – Rename file with Git

You can rename a file using gits mv command:

$ git mv file_from file_to

Example:

$ git mv helo.txt hello.txt

$ git status
# On branch master
# Changes to be committed:
#   (use git reset HEAD <file>... to unstage)
#
#   renamed:    helo.txt -> hello.txt
#

$ git commit -m renamed helo.txt to hello.txt
[master 14c8c4f] renamed helo.txt to hello.txt
 1 files changed, 0 insertions(+), 0 deletions(-)
 rename helo.txt => hello.txt (100%)

Related posts

Leave a Reply

Your email address will not be published.