{"id":19863810,"url":"https://github.com/juliabeliaeva/extractor","last_synced_at":"2026-05-19T02:02:23.472Z","repository":{"id":82182981,"uuid":"158476935","full_name":"juliabeliaeva/extractor","owner":"juliabeliaeva","description":"Scripts for extracting a part of a project into a new git repository","archived":false,"fork":false,"pushed_at":"2018-11-21T22:46:19.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-01T00:26:00.827Z","etag":null,"topics":["git","repository-management"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliabeliaeva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-21T02:04:09.000Z","updated_at":"2018-11-21T22:48:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"c285e936-d4df-461b-a605-dc3ffdd6e2eb","html_url":"https://github.com/juliabeliaeva/extractor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/juliabeliaeva/extractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliabeliaeva%2Fextractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliabeliaeva%2Fextractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliabeliaeva%2Fextractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliabeliaeva%2Fextractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliabeliaeva","download_url":"https://codeload.github.com/juliabeliaeva/extractor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliabeliaeva%2Fextractor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266561263,"owners_count":23948624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","repository-management"],"created_at":"2024-11-12T15:16:11.828Z","updated_at":"2026-05-19T02:02:23.395Z","avatar_url":"https://github.com/juliabeliaeva.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Extractor\n\nScripts for extracting a history of a subfolder of a git repository into a separate repository.\n\n#### Motivation\n\nI needed to extract a repository with [MPS Contrib](https://github.com/JetBrains/MPS-Contrib) files from the main [MPS repository](https://github.com/JetBrains/MPS). My requirements were:\n* retain file history through renames/moves, even when the files were moved outside of the specified subfolder (this allows to extract multiple folders by moving them into one subfolders first);\n* generate a nice readable history without a web of unnecessary merge commits;\n* find a solution that will work on a big repository in a reasonable time.\n\nHelpful articles:\n* [How to Move Folders Between Git Repositories](http://st-on-it.blogspot.ru/2010/01/how-to-move-folders-between-git.html)\n* [git filter-branch '--subdirectory-filter' preserving '--no-ff' merges](http://sgf-dma.blogspot.ru/2012/12/git-filter-branch-subdirectory-filter.html)\n\n#### Used approach\n\n1. For every file extract full history (with renames): all commits where the file was changed plus all the paths to the file (`smartlog.sh`). The output contains two files: `revisions.txt` with commit ids and `history.txt` with file names. File history algorithm that is used here is described in [GitFileHistory.java](https://github.com/JetBrains/intellij-community/blob/18d2398d373ea13d8618e2d5422450ccb53202da/plugins/git4idea/src/git4idea/history/GitFileHistory.java#L50) from [IntelliJ IDEA](https://www.jetbrains.com/idea/) source code.\n\n2. Create a branch only with commits in revisions.txt (`FilterByRevisions.java`). It walks all revisions from HEAD that are in revisions.txt maintaining a set of \"roots\" -- ends of current branch without parents. Every commit it tries to attach to one of the roots or their children. The output is a bash script `buildtree.sh` which generates a resulting graph of commits using `commit-tree` command.\n\n3. Execute `buildtree.sh` and checkout a `HEAD` of generated graph. If there are several heads, all but one are lost.\n\n4. Filter HEAD by paths and leave only paths from `history.txt`. This is done by `filter.sh`.\n\n#### Usage\n\nDisclaimer: this is a \"works on my machine\" project, so use at your own risk.\n\nExecute `scripts/main.sh \u003cPATH TO REPOSITORY\u003e \u003cRELATIVE PATH TO THE FOLDER TO EXTRACT\u003e`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliabeliaeva%2Fextractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliabeliaeva%2Fextractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliabeliaeva%2Fextractor/lists"}