Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2.6 KiB
2.6 KiB
title, intro, redirect_from, versions
| title | intro | redirect_from | versions | |||||
|---|---|---|---|---|---|---|---|---|
| Moving a file to a new location using the command line | You can use the command line to move files within a repository by removing the file from the old location and then adding it in the new location. |
|
|
Many files can be moved directly on {{ site.data.variables.product.product_name }}, but some files, such as images, require that you move them from the command line.
{{ site.data.reusables.command_line.manipulating_file_prereqs }}
- On your computer, move the file to a new location within the directory that was created locally on your computer when you cloned the repository. {{ site.data.reusables.command_line.open_the_multi_os_terminal }}
- Use
git statusto check the old and new file locations.
$ git status
> # On branch <em>your-branch</em>
> # Changes not staged for commit:
> # (use "git add/rm <file>..." to update what will be committed)
> # (use "git checkout -- <file>..." to discard changes in working directory)
> #
> # deleted: /<em>old-folder</em>/<em>image.png</em>
> #
> # Untracked files:
> # (use "git add <file>..." to include in what will be committed)
> #
> # /<em>new-folder</em>/<em>image.png</em>
> #
> # no changes added to commit (use "git add" and/or "git commit -a")
{{ site.data.reusables.git.stage_for_commit }} This will delete, or git rm, the file from the old location and add, or git add, the file to the new location.
$ git add .
# Adds the file to your local repository and stages it for commit.
# {{ site.data.reusables.git.unstage-codeblock }}
- Use
git statusto check the changes staged for commit.
$ git status
> # On branch <em>your-branch</em>
> # Changes to be committed:
> # (use "git reset HEAD <file>..." to unstage)
> #
> # renamed: /old-folder/image.png -> /new-folder/image.png
# Displays the changes staged for commit
{{ site.data.reusables.git.commit-file }}
$ git commit -m "Move file to new directory"
# 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 }}