How to make subfolders repository in Github - github

I've been using this folder structure where I would have one main .git folder and then have subfolders inside which doesn't have .git folder.
So as example :
Main Folder
Subfolder
Subfolder
Subfolder
Now what I want to do is, I would like to extract some of those subfolders and make them separate repositories with their histories. Which means subfolders will become a main folder as a repository. Any idea how?

The official documentation use git filter-branch.
But that or BFG are obsolete.
Use the new tool git filter-repo (directly in your regular local repository, although a backup is always a good idea before those kind of filtering)
Use a path shorcut:
git filter-repo --subdirectory-filter Subfolder1
Only look at history that touches the given subdirectory and treat that directory as the project root.
Equivalent to using --path / --path-rename /:

Related

Where is the .github folder in the project repository?

I want to add a few config files to .github folder but I can't seem to find it in my repository. I do see the .git and .gitignore files. Where can I find this .github folder, Is it added by git or should I create it?
There isn't one unless you create it (and if you do, you should create it in the root directory for the repository).

CVS ignores .git folder

I was trying to synchronize my local git repository to a CVS repository and everything gets synchronized properly, except for the .git folder.
At first, I thought all folders starting with a dot would be ignored, so I tried adding a .test folder and putting mock files in it. To my surprise, it is detected as a new folder, and the files inside of it are listed and ready to be synchronized.
How do I make CVS sync the .git folder? Thank you.
P.S. I use git locally to keep track of individual changes, and CVS for major milestones. They don't have to be linked in any form.
You definitely do not want the .git folder itself to be synced "as is" to your CVS repository.
When using git, the .git folder contains the version information, e.g. the content of all versions of all files in the repository (in a compressed format).
When you are syncing, the information in .git is used to populate the version control information in CVS. But CVS cannot read the information in the .git folder directly.
Syncing content of .git so that it would be visible in CVS would only be confusing (and dangerous if you tried to "sync back" that content to git, overwriting the contents of the .git folder in git).

Why does eGit create an extra directory in the remote repo when I do the first commit/push?

Using eGit...
When I perform the initial Commit and Push from Eclipse, a new directory appears in the remote repo. Inside that directory is the root of the project directory. It makes a big mess because when someone clones it (again using eGit) the src folder is munged into a name containing then project folder name, which mucks up the package references in the class files.
eGit assumes you don't want an entire git repository for a single workspace project. Doing so would be wasteful and cumbersome for almost anything nontrivial. https://wiki.eclipse.org/EGit/User_Guide#Implications
You also didn't commit the .classpath file, which would have indicated what the source folders were.

Can I separate `.hg` from working directory?

I would like to put directory C:\WorkDir under Mercurial version control, but have the repository located somewhere else than C:\WorkDir\.hg perhaps D:\Repositories\WorkDir.hg. Is that possible in Mercurial?
This answer on the Mercurial mailing list by Martin Geisler is quite clear about it:
You cannot move the .hg folder outside of where your working files
reside. That is by definition: the "working copy" is the parent
directory of the .hg folder. So if you want to version files in
C:\inetpub\laravel\app
you must have
C:\inetpub\laravel\app\.hg
If you want to avoid having the drive with the "real" working copy filled up with the repository data, you can use the share extension: https://www.mercurial-scm.org/wiki/ShareExtension .
E.g. if you want to version control C:\WorkingDir, but want the big repository data to reside on D:\Repositories\WorkDir, just do the following:
cd D:\Repositories
hg init WorkDir
cd C:\
hg share D:\Repositories\WorkDir WorkingDir
You will still have a .hg directory on C:, but it will remain really small (around 1MB), while the repo on D: will be the one that grows with time.
Have you tried creating a Junction?
Let's say your repo is c:\test\.hg but you want to put .hg directory in c:\shadow
mkdir c:\shadow
mv c:\test\.hg c:\shadow\.hg
mklink /j c:\test\.hg c:\shadow\.hg

Change root directory of repo in Mercurial

I'm working on an Android game with the folder structure:
\bin
\data (contains game graphics)
\libs (libgdx engine jars)
\src
----\com
--------\brand
------------\game
(*.class files)
Foolishly, I created a mercurial repository (hg init) in the \src directory. Thus, if I update any of the graphics (small file sizes), they aren't added to the repo when I commit. My question is: how can I change the root of the repo to include the \data directory as well as the \src directory, but without including the \libs directory as that includes 10-20mb jars?
There are two ways to do this.
1) Start a new repo. It's quick and easy but you'll lose your history.
2) Use hg rename. This is effectively a move command.
Rename the src directory to be something meaningful and then do this.
hg rename MyProject/com MyProject/src/com
Copy all the files/folders into the MyProject/ directory.
Mark bin and libs as ignorable and
Add everything else.
hg commit
If you don't want to just do an hg rename, you can do it with the convert extension (which comes by default with Mercurial, you just need to enable it in your .hgrc).
Run it with the --filemap parameter and a filemap file that has something like:
rename com src/com
You will end up with a new repository with all of your history, but with your com directory moved into src/com. You can then copy you bin, data and libs folders in there, run hg addremove and you should be all good to go.
Warning: the new repo is completely different than the old one -- changeset IDs and such will be different, so anybody you worked with in the past will have to get on the new repo.