splitsh / lite

Split a repository to read-only standalone repositories
MIT License
1.54k stars 69 forks source link

Split examples with push and some monorepo questions #55

Open bvdham opened 4 years ago

bvdham commented 4 years ago

I'm not sure if this is the place to ask for some examples while trying to split and push a sub packe to a new repo. Maybe an examples could eventually be added to the main readme.

I'm trying to build my own monorepo https://github.com/symmono/symmono with for example a sub package framework-bundle https://github.com/symmono/framework-bundle.

On the main branch (master) i'm running

# splitsh, trying to split the master branch FrameworkBundle to it's own repo
git splitsh --prefix=packages/Symmono/Bundle/FrameworkBundle

# sha1
0 commits created, 0 commits traversed, in 0s
c5a195e73c6e2317f44fae252c1d2ae3beb323e7
  1. Is there a command to see whats in that sha1?

Now i'm trying to push it to the framework-bundle repo

# at this moment the framework-bundle is an empty repo
# command 1 with respone
git push git@github.com:symmono/framework-bundle.git c5a195e73c6e2317f44fae252c1d2ae3beb323e7

fatal: c5a195e73c6e2317f44fae252c1d2ae3beb323e7 cannot be resolved to branch

# command 2 with respone
git push git@github.com:symmono/framework-bundle.git c5a195e73c6e2317f44fae252c1d2ae3beb323e7:master

error: unable to push to unqualified destination: master
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'git@github.com:symmono/framework-bundle.git'

Can't get my head around it how to split and push it to a new repo. And how to push to a branch and is it possible with splitsh to use tags.

  1. How does the --target flag works?
    
    # branch split example
    # when reading readme the --target flag shoud automatically create a branch for the split by passing a branch name, when running below command om main master monorepo
    git splitsh --prefix=packages/Symmono/Bundle/FrameworkBundle --target=origin/0.1
    0 commits created, 0 commits traversed, in 8ms
    c5a195e73c6e2317f44fae252c1d2ae3beb323e7

trying to push to branch

git push git@github.com:symmono/framework-bundle.git c5a195e73c6e2317f44fae252c1d2ae3beb323e7 0.1 error: src refspec 0.1 does not match any. error: failed to push some refs to 'git@github.com:symmono/framework-bundle.git'



Above split and push commends are apparently not the way to go.

3. How could i split and push the sha1 to an new repo.
4. Is it possible to split and push with tags?

Some extra questions

5. Do you always split of the master branch, when or why to split a branch.
6. When working with tags, for example v2.1.2 should you work on branch 2.1 and consider the master branch as new released branch. In this example for v2.2?
dluague commented 4 years ago

I have success using Laravel sh file https://github.com/laravel/framework/blob/7.x/bin/split.sh.

Step 1: Commit everything in your main repo. make sure the sub package you want to split don't have git initialized. Step 2: Create a new remote repository for the sub package. Step 3: Edit the necessary information in the Laravel split.sh file. Step 4: Run the split.sh file.

Note: Run split.sh file every time you have a new commit in your main repo to sync everything in your sub packages.

bvdham commented 4 years ago

@dluague Thank you, that could help me out. Question is it also possible to use tags?

dluague commented 4 years ago

@bvdham you need to use their release.sh for tag support. https://github.com/laravel/framework/blob/7.x/bin/release.sh

bvdham commented 3 years ago

Some examples here would be nice.