Hlanza umlando we-Git ingxenye yesi-2

Idatha ebucayi noma ukusetshenziswa kwememori kakhulu: Kunezizathu ezinhle zokufuna ukushintsha umlando we-Git. Kulokhu okuthunyelwe kwebhulogi , ngichaze ukuthi uwahlanza kanjani amafayela emlandweni we-Git usebenzisa i- BFG . Iphuzu elibuthakathaka le-BFG ukuntuleka kokusekelwa kwezindlela eziqondile , ngakho awukwazi ukususa ngokuqondile amafayela noma amafolda kumafolda amancane emlandweni. Ngalokho, sekuyisikhathi sokubheka ezinye izixazululo.


Ngaphezu kwegatsha lesihlungi le-git elinganconyiwe ngokusemthethweni , i-git-filter - repo ingelinye lamathuluzi okuhlanza umlando. Ngemva kokufaka okufushane , siqale sihlaziye inqolobane bese sithola, isibonelo, amafolda amakhulu kunawo wonke emlandweni:

git filter-repo --analyze

Kuhle kube kufolda .git/filter-repo/analysis ikhiqize zonke izinhlobo zamafayela e-TXT:

  • directories-all-sizes.txt
  • extensions-all-sizes.txt
  • path-all-sizes.txt
  • ...

Kuyafaneleka ifayela directories-all-sizes.txt bhekisisa:

=== All directories by reverse size ===

Format: unpacked size, packed size, date deleted, directory name

  4624417043 3796607988 <present> <toplevel>
  4475940396 3778033787 <present> wp-content
  4060236681 3694449320 <present> wp-content/uploads
   305163809   70576241 <present> wp-content/plugins
   123818107   15442735 <present> wp-includes
...

Kuvame ukwenzeka ukuthi usunesikhathi eside ungaziba futhi wasusa kudatha ye-HEAD emlandweni (isibonelo, ifolda yemidiya ye-WordPress wp-content/uploads/ noma ophushwe ngephutha node_modules- noma vendor- Isibopho).

Okubalulekile, amapulatifomu amakhulu wokubamba amakhodi IGitHub futhi I-GitLab batusa izindlela ezehlukene, ezinye zazo ezihlukile kwenye. Isibonelo, ku-GitHub siyasusa wp-content/uploads/ usebenzisa izinyathelo ezilandelayo git-filter-repo kusukela emlandweni:

mkdir tmp-repo
cd tmp-repo
git clone git@github.com:foo/bar.git .
cp .git/config /tmp/config-backup
git filter-repo --invert-paths --path wp-content/uploads
mv /tmp/config-backup .git/config
git push origin --force --all
git push origin --force --tags
# check size locally
git gc && git count-objects -vH
cd ..
rm -rf tmp-repo

Manje singakwazi futhi ukuhlola usayizi ukude (ukushintsha usayizi nge-API futhi ku-UI kungathatha amahora angafika kwangu-24). Ukuze wenze lokhu, vula izilungiselelo zendawo yokugcina (uma inqolobane ingeyenhlangano, kufanele uqale wengeze i-akhawunti yakho enhlanganweni). Manje sibona ubukhulu:

I-GitHub: isikhala sediski ngaphambi kokuhlanza
I-GitHub: isikhala sediski ngemva kokuhlanza

Inqubo ihluke kancane ku-GitLab:

mkdir tmp-repo
cd tmp-repo
# Settings > General > Advanced > Export project > download tar.gz file into tmp-repo
tar xzf 20*.tar.gz
git clone --bare --mirror project.bundle
cd project.git
git filter-repo --invert-paths --path wp-content/uploads/
cp ./filter-repo/commit-map /tmp/commit-map-1
# copying the commit-map has to be done after every single command from git filter-repo
# you need the commit-map files later
git remote remove origin
git remote add origin git@gitlab.com:foo/bar.git
# Settings > Repository > Protected branches/Protected branches >
# enable "Allowed to force push to main/master"
git push origin --force 'refs/heads/*'
git push origin --force 'refs/tags/*'
git push origin --force 'refs/replace/*'
# Settings > Repository > Protected branches/Protected branches >
# disable "Allowed to force push on main/master"
cd ./../../
rm -rf tmp-repo
date
# wait 30 minutes (😱)
date
# Settings > Repository > upload /tmp/commit-map-X

Ngemuva kokulinda okunye okungamaminithi angu-5 singangena ngaphansi Settings > Usage Quotas buka indawo yokugcina:

I-GitLab: isikhala sediski ngaphambi kokuhlanza
I-GitLab: isikhala sediski ngemva kokuhlanza

Ngemva kokususwa, kubalulekile ukuthi bonke onjiniyela abahilelekile bahileleke ezinyathelweni zokugcina: Uma umsebenzisi manje enza ukucindezela okuvamile ngekhophi yakhe yendawo, lokhu kuzophumela ekuthutheleleni kwamafayela amakhulu abuyele endaweni yokugcina emaphakathi. Ngakho-ke, lezi zinketho ezi-3 ezilandelayo ziyanconywa:

  • rm -rf .git && git clone xxx temp && mv temp/.git ./.git && rm -rf temp && git add -A .
    ("i-clone entsha yomuntu ompofu", yenza kabusha endaweni yokugcina ekhona)
  • rm -rf repo && git clone xxx .
    ("qala kusukela ekuqaleni", okuhlukile okuhlanzekile)
  • git pull -r
    ("donsa ngokuhlehlisa", usenomlando ongahlanzekile, kodwa awusawubhali ngephutha)

Ngokuhamba kwezabelo zamanje (ikakhulukazi ngenxa yemikhawulo emisha ye-GitLab ), kuhlale kufanelekile ukuhlola usayizi womlando wamaqoqo akho futhi uwahlanze uma kunesidingo.:

I-GitHub MahhalaI-GitLab Mahhala
Umkhawulo kasayizi wefayela omkhulu100MB
Umkhawulo kasayizi we-repo omkhulu5,000MB
Umkhawulo wokubala we-repo
Umkhawulo kasayizi uwonke5,000MB

Okokugcina, kufanelekile futhi ukuthi sibheke ukusingathwa kwakho, okuhlukile kwamahhala njenge -Gitea . Ngomzamo omncane, ungakwazi ukusingatha isibonelo se-Git esizibambele wena (i-GUI evikelwe i- SSL , ikhophi yasenqolobaneni ifakiwe, lawula nge -API enamandla ) kuseva ethambile kakhulu , engalungiselelwa kahle kakhulu futhi futhi iphakeme ngokwemibandela yokuvikela idatha.

Emuva