Mercurial(hg) copying part of repository into another rpository - version-control

I have two repositories:
Repository A is empty.
Repository B with:
module1
module2
module3
How i can copy module1 from repository B into repository A with all relevant commit history?

Convert /module1 into independent repo
Force pull (because they are unrelated) module1-repo to A

Related

How to combine two repository converted from SVN and keep the commit history

I have two projects on SVN, I want to combine them into one Github repo and keep the respect SVN commit history.
projectA:
https://svn-pro.net/svn/clients/trunk/TC/Source_Code/projectA
ProjectB:
https://svn-pro.net/svn/clients/trunk/TC/Source_Code/ProjectB
projectC:
https://github.azc.com/ming/ProjectC
repo ProjectC's content looks like this:
d:projectA
d:ProjectB
f:README
My plan is to use "git svn clone" to convert projectA and projectB into two Github repos and then combine them in to Github repo projectC. Is this the correct and best way to do it?
Is it possible to put two converted local repo projectA and projectB (generated by "git svn clone") into one folder and do some config and direct commit this combined local repo into Github repo projectC ?
"git svn clone" process:
https://learn.microsoft.com/en-us/azure/devops/repos/git/perform-migration-from-svn-to-git?view=azure-devops

what's the correct way to re-organize github repos?

I used to put all files in one repo, recently I wanted to subdivide them into several repo with different topics. So I turned my original repo into a subfolder and added some more folders and committed. While the original repo still works, when I want to commit to the other repos via terminal, it's giving me error
ERROR: Repository not found.
fatal: Could not read from remote repository.
The other repos still show as different repo on my github accounts.
Now when I cd into one of subfolders and do git pull, the content flow in to git_repo master folder instead of subfolder
What's the right way to re-organize repos?
You can use git submodules :
It often happens that while working on one project, you need to use
another project from within it. Perhaps it’s a library that a third
party developed or that you’re developing separately and using in
multiple parent projects. A common issue arises in these scenarios:
you want to be able to treat the two projects as separate yet still be
able to use one from within the other.
Given the following structure, you could make project1 & project2 submodules :
project-root/
├── project1/
│ └── file_from_project1.txt
├── project2/
│ └── file_from_project2.txt
└── project-root-folder/
└── file_from_project_root.txt
This could be done using :
cd project-root
git submodule add https://github.com/user/repo-for-project1 project1
git submodule add https://github.com/user/repo-for-project2 project2
Then, when you enter project1 & project2 folder you will be entering the git repo of these projects and will be able to pull & push from/to the Github repo.
On Github UI you will see ther submodules in your root project:

Using common Jekyll code for multiple github pages websites

I'm wanting to have both a user website and multiple project websites hosted on Github Pages i.e.
username.github.io
username.github.io/project1
username.github.io/project2
I'd like them to share a common set of jekyll files so it's easier to change themes, info, etc.. Has anyone managed to do this? Using subtree / submodule isn't too helpful because you cannot overwrite the source config option to change the location of the jekyll source files. Github Pages always forces the source to be in the root directory. You can change where _includes and _layouts reside but that's not too useful. Any advice or examples?
Use username.github.ui/base as your repository with your base templates. This shouldn't be a gh-page.
This repository should contain a branch with your base templates. For the moment, I say you are using the master branch for that. Branch out and create a project1 and project2 branch in this repo.
Every time you change your base templates, change them in the master branch and then merge the master branch into project1 and project2.
Clone the base repo locally, and add project1 and project2 both as remotes.
Then simply do a git push project1 project1:gh-pages to push your local project1 branch to the first projects gh-pages branch.
This will still multiply the files, but it will mean that you can easily keep them in sync. Changing your base templates would be like this:
git pull project1's gh-pages branch into the base repos project1 branch. Repeat for project2.
Change the base templates in the appropriate branch in the base repo.
Merge the branch into the project1 and project2 branches
git push project1's branch into project1sgh-pages` branch. Repeat for #2.
If you set up some hooks this can be automated fairly easy.

Splitting GitHub releases

I just migrated an old project from an own Subversion/Trac infrastructure to GitHub
https://github.com/matteocorti/nagios_plugins
The repository contains one directory for each plugin I wrote. Each plugin is standalone and has an own version number (but the source code is in the same repository).
When I release a new plugin version I would like to have a release with just the corresponding folder (e.g., https://github.com/matteocorti/nagios_plugins/tree/master/check_updates)
Is there a way with the GitHub release feature to select which part of a repository contains the software to be released?
Another option would be to split the whole and have a repository for each plugin. This would imply that I will have to manually move all the issues/bugs and wiki pages.
Edit
It seems that the only solution would be to split the repository (a separate repository for each plugin).
How can I split a Git repository retaining the commit history?
It seems that the only solution would be to split the repository (a separate repository for each plugin).
It is, but that does not migrate wiki pages and issues.
To split a git repo while keeping the history, see GitHub page "Splitting a subfolder out into a new repository"
git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
git filter-branch --prune-empty --subdirectory-filter \
YOUR_FOLDER_NAME master
# Filter the master branch to your directory and remove empty commits
# Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (89/89)
# Ref 'refs/heads/master' was rewritten
The repository now contains all the files that were in your subfolder.
Note that although all of your previous files have been removed, they still exist within the Git history. You can now push your new local repository to a new repository on GitHub.
Check also "How to tear apart a repository: the Git way "
Once you have one repo per plugin, you can still register them in your original repo, as git submodules.
Edit
To push the subfolder to a new repository
git remote rename origin upstream
git remote add origin NEW_URL
git push origin master

Cloning a git repo that has submodules

I have a git repot that has a submodule.
I want to clone this repo into an eclipse workspace, I've read this
Working with Submodules
You can read more about what Git submodules are and how they work in this Git Community Book chapter.
Cloning Repositories with Submodules
Submodules are repositories nested inside a parent repository.
Therefore when doing a clone of a parent repository it is necessary to
clone the submodule repositories so that the files/folders are
available in the parent repository's working directory.
Checking the Clone Submodules button from the Git Clone wizard will clone all submodule repositories after the clone of the parent
repository finishes.
However, when I am done cloning, the submodule directory is empty
and the project doesnt appear in the workspace.
How do I add the submodule ?
in eclipse go to git explorer perspective
you can import you project modules under you project
project> working directory > select sub module > import project.
>> Import as general project (for new)
>> Import existing project (which will replace you current project)
if you have 3 modules you need to import one by one. as existing module or new one
git clone yourProjectUrl.
in your project folder: git submodule init (only do it first time)
you can also update submodule: git submodule update.