Skip to content

Instantly share code, notes, and snippets.

@amaslenn
Created May 25, 2017 08:10
Show Gist options
  • Save amaslenn/4daa4ecbbdd3418f53127d04c1a2a353 to your computer and use it in GitHub Desktop.
Save amaslenn/4daa4ecbbdd3418f53127d04c1a2a353 to your computer and use it in GitHub Desktop.

I don't care about history

git remote add secret_prefix-tools ssh://amaslenn@server.com:1234/secret_prefix-tools
git fetch secret_prefix-tools
git branch tools secret_prefix-tools/master
git read-tree --prefix builder/ -u tools:builder
git commit

Or just copy-paste files and commit it :) It is not a git way, but there is no difference at all.

History is everything I need!

This part is more tricky. I didn't found an easy way to do it (probably I was looking for the most tricky one from the beginning, but still).

Get repo

git remote add secret_prefix-tools ssh://amaslenn@server.com:1234/secret_prefix-tools
git fetch secret_prefix-tools
git branch tools secret_prefix-tools/master

Filter branch

git filter-branch --prune-empty --subdirectory-filter builder tools

Add subtree (since directory builder/ already exist, create temp directory)

git subtree add --prefix temp tools

Move all files from temp/ to builder/

git commit -m "Move secret_prefix-tools/builder/* files to builder/ folder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment