Skip to content

Turn git directories into their very own repositories in their own location. No subtree funny business.

License

Notifications You must be signed in to change notification settings

vangorra/git_split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OS Build Status
Linux Build Status
OSX Build Status
Windows Build status

MIT License

git_split.sh

This script will take an existing directory in your git repository and turn that directory into an independent repository of its own. Along the way, it will copy over the entire change history for the directory you provided. Inspiration for this script came from https://help.github.com/articles/splitting-a-subfolder-out-into-a-new-repository/. This script really just automates the process. Let me know if you find this script useful. I'm also totally open contributors.

Installation

Drop it into a appropriate bin directory. Or run it locally.

Usage

./git_split.sh <src_repo> <src_branch> <relative_dir_path> <dest_repo>
        src_repo  - The source repo to pull from.
        src_branch - The branch of the source repo to pull from. (usually master)
        relative_dir_path   - Relative path of the directory in the source repo to split.
        dest_repo - The repo to push to.

Examples

So you've been using git and storing multiple projects in the same repo. You repo looks something like this.

  • myrepo
    • /ProjectA
      • Makefile
      • README
      • src
        • file1
        • file2
    • /ProjectB
      • Makefile
      • README
      • src
        • fileA
        • fileB

Copy over the master branch.

> mkdir ProjectARepo
> git init ProjectARepo

# copy over the master branch
> ./git_split myrepo master ProjectA ProjectARepo

Notes

  • git_split does not make any modifications to your original repo. It simply copies the history from one repo to another.
  • You can copy more than 1 branch into a destination directory by running it multiple times.

Compatibility

  • Linux
  • OSX
  • Windows (with cygwin)

Requirements

  • git
  • standard *nix commands

About

Turn git directories into their very own repositories in their own location. No subtree funny business.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages