This is my Git repository:


It has a dir named local and I want to change its name to another name (say, from local to xyz).

Changing it through GitHub GUI manually is a nightmare as I have to change the directory name for each file separately (GitHub has yet to include a "Directory rename" functionality, believe it or not).

After installing Git, I tried this command:

git remote https://github.com/benqzq/ulcwe && git mv local xyz && exit

While I didn't get any prompt for my GitHub password, I did get this error:

fatal: Not a git repository (or any parent up to mount point /mnt/c)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I know the whole point in Git is to download a project, change, test, and then push to the hosting provider (GitHub in this case), but to just change a directory, I desire a direct operation. Is it even possible with Git?

Should I use another program maybe?

  • 2
    No, direct remote operations are not possible in Git. You do have to clone (download) the project, change it, then push back to the hosting provider. But how are you even using Github without having the project on your computer? Are you making all the changes through the Github web UI - that doesn't sound very convenient or efficient.
    – user253751
    Feb 14, 2018 at 22:33
  • In this particular case using the UI is usually quite convenient and efficient for me, the main thing I miss is the direct dir name change... Feb 14, 2018 at 23:08

3 Answers 3


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.

  • 14
    In other words, it's just like any other operation on the files in your Git repository. Feb 14, 2018 at 15:46
  • 2
    @LightnessRacesinOrbit the asker appears to have been using the web UI for all their changes so far.
    – user253751
    Feb 14, 2018 at 22:35

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.

  • 8
    No, history is not stored as changes between commits, each commit is self-supporting. Changes between commits are re-calculated on request every time they’re needed. Feb 14, 2018 at 14:22
  • 3
    "all history is downloaded to every single location" - not with git clone --depth
    – user11153
    Feb 14, 2018 at 14:41
  • 2
    History rewriting wouldn't be required for this -- GitHub could just generate a commit doing so. (Just as it already does when editing files directly on the website.)
    – user1686
    Feb 14, 2018 at 19:08

It is possible to rename a directory without cloning the repository, using the GitHub API. I am unaware of any implementation.

Source: https://stackoverflow.com/a/31567094/370786

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.