1
0
mirror of synced 2025-12-22 19:34:15 -05:00
Files
docs/content/github/managing-files-in-a-repository/renaming-a-file-using-the-command-line.md
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

1.7 KiB

title, intro, redirect_from, versions
title intro redirect_from versions
Renaming a file using the command line You can use the command line to rename any file in your repository.
/articles/renaming-a-file-using-the-command-line
free-pro-team enterprise-server
* *

Many files can be renamed directly on {{ site.data.variables.product.product_name }}, but some files, such as images, require that you rename them from the command line.

{{ site.data.reusables.command_line.manipulating_file_prereqs }}

{{ site.data.reusables.command_line.open_the_multi_os_terminal }} {{ site.data.reusables.command_line.switching_directories_procedural }} 3. Rename the file, specifying the old file name and the new name you'd like to give the file. This will stage your change for commit.

$ git mv <em>old_filename</em> <em>new_filename</em>
  1. Use git status to check the old and new file names.
$ git status
> # On branch <em>your-branch</em>
> # Changes to be committed:
> #   (use "git reset HEAD <file>..." to unstage)
> #
> #     renamed: <em>old_filename</em> -> <em>new_filename</em>
> #

{{ site.data.reusables.git.commit-file }}

$ git commit -m "Rename file"
# Commits the tracked changes and prepares them to be pushed to a remote repository.
# {{ site.data.reusables.git.reset-head-to-previous-commit-codeblock }}

{{ site.data.reusables.git.git-push }}

Further reading