Moving files in a GitHub repository without moving them on my computer

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.

Hi JoeKM888! :wave: 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 files and folders around on the command line in Unix type systems:

(If you’re a Windows user, I recommend you download and use Git Bash for Windows:

https://gitforwindows.org/

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:

https://help.github.com/en/github/managing-files-in-a-repository/moving-a-file-to-a-new-location-using-the-command-line