Change a directory name in a Github repository remotely, directly from local Linux Git?

The fatal error message indicates you’re working from somewhere that’s not a clone of your git repository. So let’s start by cloning the git repository first:

git clone https://github.com/benqzq/ulcwe.git

Then enter it:

cd ulcwe

and rename the directory:

git mv local xyz

For the change to be shareable, you need to commit it:

git commit -m "Rename local to xyz"

Now you can push it to your remote git repository:

git push

and you’ll see the change in the GitHub interface.


No, there is no way to do this as a direct operation because of the way git is structured.

The way that git works is that it stores a copy of the entire repository, including all history, to every single location.

Github, or Bitbucket, or any other hosting provider is essentially just another copy of your git repository, with a pretty web interface on top, which is treated as a central source of truth in most workflows, however the git utility does not know this.

Changes are tracked as commits. I'm guessing that by direct operation, you mean a way of changing the folder's name without creating a commit. While this is possible by rewriting history, I would not recommend it, especially if there are multiple people/machines with copies of the git repo, as this can lead to inconsistencies.

The easiest way to rename a folder in a git repo would be to clone it locally

git clone [url]
cd [git-folder]

If you already have a local copy of the repo, pull it to ensure you are up to date to the remote repo

git pull

Make the changes you need to locally

git mv local xyz

Which should automatically be added to the staging area by github. Then you should commit and push these changes.

git commit -m 'Renamed local to xyz'
git push

This will commit the change to your local repository, then push these changes to the remote copy of the repository, in this case, Github.