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).
Ngokuvamile incoma git-filter-repo
ngemva kokuhlanza, ukuphushela endaweni yokugcina, engenalutho. Kunezizathu eziningi ezibalwe lapha, kungani lokhu kunengqondo futhi kugwema izinkinga eziningi. Noma kunjalo, kungenzeka ukuthi ufune ukuphushela endaweni yokugcina efanayo futhi lokho kungenzeka nangamacebiso ambalwa.
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/
# option 1: same repo
mv /tmp/config-backup .git/config
git push origin --force --all
# option 2: new repo
git remote add origin git@github.com:foo/bar-new.git
git push origin --force --all
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:
Inqubo ihluke kancane ku-GitLab:
mkdir tmp-repo
cd tmp-repo
# option 1: same 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 to main/master"
date
# wait 30 minutes (😱)
date
# Settings > Repository > upload /tmp/commit-map-X
# option 2: new repo
git clone git@gitlab.com:foo/bar.git .
git filter-repo --invert-paths --path wp-content/uploads/
git remote add origin git@gitlab.com:foo/bar-new.git
# Settings > Repository > Protected branches/Protected branches >
# enable "Allowed to force push to main/master"
git push origin --force --all
# Settings > Repository > Protected branches/Protected branches >
# disable "Allowed to force push to main/master"
cd ..
rm -rf tmp-repo
Ngemuva kokulinda okunye okungamaminithi angu-5 singangena ngaphansi Settings > Usage Quotas
buka indawo yokugcina:
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:
- "i-clone entsha yomuntu ompofu"
rm -rf .git && git clone xxx temp && mv temp/.git ./.git && rm -rf temp
- Okwamafayela ashintshiwe (kuya ngohlelo lokusebenza):
git checkout -- .
noma.git add -A . && git commit -m "Push obscure file changes." && git push
- "qala kusukela ekuqaleni"
rm -rf repo && git clone xxx .
- "donsa kabi nge-rebase"
git pull -r
- Lapha usenomlando ongahlanzekile, kodwa ezimweni eziningi awusabhali ngephutha inqolobane ekude ngokuhluka okukhulu kwendawo.
Ngokuhamba kwezabelo zamanje (ikakhulukazi ngenxa yemikhawulo emisha ye-GitLab ), kuhlale kufanelekile ukuhlola usayizi womlando wamaqoqo akho futhi uwahlanze uma kunesidingo.:
I-GitHub Mahhala | I-GitLab Mahhala | |
Umkhawulo kasayizi wefayela omkhulu | 100MB | ∞ |
Umkhawulo kasayizi we-repo omkhulu | 5,000MB | ∞ |
Umkhawulo wokubala we-repo | ∞ | ∞ |
Umkhawulo kasayizi uwonke | ∞ | 5,000MB |
Okokugcina, kuhle futhi ukuthi sibheke okuzibambele wena, okuhlukile kwamahhala njengo Gitea ukulahla. Ngomzamo omncane ongakwenza ku iseva encane kakhulu isibonelo se-Git esizibambele sona (i-GUI nge I-SSL ivikelekile, Isipele kuhlanganisiwe, ukulawula i-API enamandla) umsingathi, nazo ezinhle kakhulu lungisa futhi futhi iphakeme ngokwemibandela yokuvikela idatha. Lapha, ngendlela, ungasebenzisa futhi git-filter-repo
Vele uqondise amakhosombe:
mkdir tmp-repo
cd tmp-repo
git clone git@git.tld.com:foo/bar.git .
cp .git/config /tmp/config-backup
git filter-repo --invert-paths --path wp-content/uploads/
# option 1: same repo
mv /tmp/config-backup .git/config
git push origin --mirror
# login on the remote command line and run in the repo-folder
sudo -u git git reflog expire --expire=now --all
sudo -u git git gc --aggressive --prune=now
# if you face memory limit issues, modify the git configuration
sudo -u git git config --global pack.windowMemory "100m"
sudo -u git git config --global pack.packSizeLimit "100m"
sudo -u git git config --global pack.threads "1"
# if in web ui the size does not change, make a slight
# modification to a file and push again normally
# option 2: new repo
git remote add origin git@git.tld.com:foo/bar-new.git
git push origin --force --all
cd ..
rm -rf tmp-repo
Nanku umyalo ngokuqondile sudo -u git git gc --aggressive --prune=now
okubalulekile (i-cron egijima git gc
uma kungenjalo uneyodwa ende kakhulu lungisa isikhathi amaviki ama-2).