git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Question relate to collaboration on git monorepo

From
ZheNing Hu <adlternative@gmail.com>
Date
Sep 20, 2022, 12:42 UTC
Message-ID
<CAOLTT8SHo66kGbvWr=+LQ9UVd1NHgqGGEYK2qq6==QgRCgLZqQ@mail.gmail.com>
Hey, guys,

If two users of git monorepo are working on different sub project /project1 and /project2 by partial-clone and sparse-checkout , if user one push first, then user two want to push too, he must pull some blob which pushed by user one. I guess their repo size will gradually increase by other's project's objects, so is there any way to delete unnecessary blobs out of working project (sparse-checkout filterspec), or just git pull don't really fetch these unnecessary blobs?

The large number of interruptions in git push may be another problem, if thousands of probjects are in one monorepo, and no one else has any code that would conflict with me in any way, but I need pull everytime? Is there a way to make improvements here?

Here's an example of how two users constrain each other when git push.
#!/bin/sh
rm -rf mono-repo
git init mono-repo -b main
(
  cd mono-repo
  mkdir project1
  mkdir project2
  for ((i=0;i<10;i++))
  do
    echo $i >> project1/file1
    echo $i >> project2/file2
  done
  git add .
  git commit -m init
)

rm -rf mono-repo.git git clone --bare mono-repo

# user1
rm -rf m1
git clone --filter="blob:none" --no-checkout --no-local ./mono-repo.git m1
(
  cd m1
  git sparse-checkout set project1
  git checkout main
  for ((i=0;i<10;i++))
  do
    echo "data1-$i" >> project1/file1
    git add .
    git commit -m "c1 $i"
  done
)
# user2
rm -rf m2
git clone --filter="blob:none" --no-checkout --no-local ./mono-repo.git m2
(
  cd m2
  git sparse-checkout set project2
  git checkout main
  for ((i=0;i<10;i++))
  do
    echo "data2-$i" >> project2/file2
    git add .
    git commit -m "c2 $i"
  done
)
# user1 push
(
  cd m1
  git push
)
# user2 push failed, then pull user1's blob
(
  cd m2
  git cat-file --batch-check --batch-all-objects | grep blob | wc -l >
blob_count1
  git push
  git -c pull.rebase=false pull --no-edit #no conflict
  git cat-file --batch-check --batch-all-objects | grep blob | wc -l >
blob_count2
  diff blob_count1 blob_count2
)

-- ZheNing Hu

Next: Emily Shaffer
Message 1 of 12 in “Question relate to collaboration on git monorepo”
  1. ZheNing HuSep 20, 2022
  2. Emily ShafferSep 20, 2022
  3. ZheNing HuSep 21, 2022
  4. Elijah NewrenSep 21, 2022
  5. Derrick StoleeSep 22, 2022
  6. Emily ShafferSep 22, 2022
  7. Elijah NewrenSep 23, 2022
  8. Junio C HamanoSep 23, 2022
  9. Derrick StoleeSep 23, 2022
  10. ZheNing HuSep 23, 2022
  11. Elijah NewrenSep 21, 2022
  12. ZheNing HuSep 21, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.