Home > Back-end >  How to change the folder structure of my GitHub repository?
How to change the folder structure of my GitHub repository?

Time:04-05

I am new to GitHub and I am currently learning how to use it. I have changed the folder structure of my local repo on my PC and I want to somehow push those changes on GitHub. Essentially, I have moved all of my files from my local repo to a new sub-folder of my original repo. (as I am planning to add more sub-folders) now on my PC looks like I want, but not on GitHub.

I have tried to "Sync" the local repo with the one on Github, but this does not help. If I make a change on one of the files or I create a new file on the local repo and commit this change, it gets changed on GitHub, but this is not the case if I move all files to a new subfolder.

For example:

My GitHub is like this: File 1, File 2, File 3... etc. On my PC looks like this C#> File 1, File 2, File 3...

I want to have this C# folder in both GitHub and my local repo.

Thank you in advance!

CodePudding user response:

You stated in a comment:

.git is within the C# folder.

Note that all of the folders and files (as well as the subfolders of these folders upto any level within) in the same directory as the directory .git folder is in are what are visible to git. So, in your case, the C# folder is not visible to git since the .git folder is within the C# folder.

If you want the C# folder to be visible to git, you need to navigate to one of this folder's parent folder and git init in that parent folder.

You should also use .gitignore file and place it in the same folder that the .git folder is in to provide rules to exclude files and folders from source control.

tl;dr: You can go ahead and delete your current .git folder (after taking due diligence backup of the files currently under source control) and navigate to one of the parent folder and initialize your repository from scratch.

  • Related