+2 votes
1 view
in DevOps and Agile by (19.8k points)

I have 2 directories on my GitHub repository. I'd like to delete one of them. How could I do that without deleting and re-creating the entire repository?

1 Answer

+2 votes
by (63.4k points)

Remove directory from git and local

You could checkout 'master' with both directories;

git rm -r one-of-the-directories

git commit -m "Remove duplicated directory"

git push origin <your-git-branch>

Here, <your-git-branch> is typically the 'master' branch, but not always/

Remove directory from git but NOT local

If you want to remove this directory from git but not delete it entirely from the filesystem (local system)

In that case, you have to use:

git rm -r --cached myFolder

Want to learn more about frequently used commands in Git? Then visit git commands now.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !