Moving files in a GitHub repository without moving them on my computer #23756
-
I created a 2nd GitHub project in it’s repository in GitHub, but it copied my file structure across so now the project (a web site) is buried in several levels of folders. I want to move all the files to the top level of the repository, but when I looked up moving files it said I should move them on my own computer. I don’t want to move the files on my computer, just in the GitHub repository. It does work, it’s just a long URL at the moment. If I can do this from the command line interface it would be best as there are images involved, and I want to become more familiar with the CLI. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi JoeKM888! 👋 Moving files in the GitHub web UI is a bit of a pain. You can move files one by one by editing them and then editing the file path: https://help.github.com/en/github/managing-files-in-a-repository/moving-a-file-to-a-new-location That won’t work on some types of files that can’t be edited in the UI, such as images or PDFs, and in any case, moving them one by one is not very practical! So the solution is indeed to move the folder on your local copy, and then push the change to GitHub. (This is how using the CLI to move things works too - you move you local copy, then push the change.) Here’s a helpful article that explains how to use the Linux and Unix mv command tutorial with examples | George OrnboTutorial on using mv, a UNIX and Linux command to move or rename files. Examples of moving a file, moving multiple files, moving a directory, prompting before overwriting and taking a backup before moving. (If you’re a Windows user, I recommend you download and use Git Bash for Windows: It uses Unix style syntax for commands, and you will find that almost all tutorials, blog posts, and stack overflow answers use the same syntax, so it will make everything easier in the future.) After you’ve moved the folder, here’s how to commit and push the change: |
Beta Was this translation helpful? Give feedback.
Hi JoeKM888! 👋 Moving files in the GitHub web UI is a bit of a pain. You can move files one by one by editing them and then editing the file path:
https://help.github.com/en/github/managing-files-in-a-repository/moving-a-file-to-a-new-location
That won’t work on some types of files that can’t be edited in the UI, such as images or PDFs, and in any case, moving them one by one is not very practical!
So the solution is indeed to move the folder on your local copy, and then push the change to GitHub. (This is how using the CLI to move things works too - you move you local copy, then push the change.)
Here’s a helpful article that explains how to use the
mv
command, which is how you move file…