考虑存储库中极大的.git文件夹

时间:2017-02-02 13:46:54

标签: git filesize pruning

我有一个287M的客户端存储库。它大约有2年半的历史,而且这个尺寸对于我所做的回购并不常见。什么 IS 不寻常的是,181M是.git文件夹。

没有过多的分支,为此我总是认为分支本身不会占用那么多空间,它只是一个指针。但如果这是错误的,请纠正我。

我的问题与导航相关(当然还有修复):

  1. 如何确定哪个文件对此负责?
  2. 有一个db_dump.sql.gz文件愚蠢地包含在回购中。如何删除该文件并将其从git历史中完全删除,就像它从未存在过一样? (它是16M,但我在想是否一个自动化流程定期转储该文件,并且这些更改已经提交,这可能是大尺寸原因的一部分)。
  3. 如果有的话,有什么方法可以减少git repo的大小?感谢。

1 个答案:

答案 0 :(得分:0)

你可以运行<script> var container, camera, scene, renderer, controls; // PI var PI = Math.PI; var TWO_PI = PI*2; // size SCREEN_WIDTH = window.innerWidth; SCREEN_HEIGHT = window.innerHeight; SCREEN_PIXEL_RATIO = window.devicePixelRatio; // camera var VIEW_ANGLE = 45; var ASPECT = SCREEN_WIDTH / SCREEN_HEIGHT; var NEAR = 0.1; var FAR = 20000000; // video raster var video; var videoImage; var videoImageContext; var _imageHeight; var _imageWidth; // lines var _lineGroup; // gui var _guiOptions = { stageSize: 1, scale: 1.0, scanStep: 5, lineThickness: 10.0, opacity: 1.0, depth: 50, autoRotate: false }; // triggered from audio.php getMediaStream function runme() { console.log('runme running'); init(); animate(); } runme(); function init() { container = document.createElement('div'); document.body.appendChild(container); //---------- // scene //---------- scene = new THREE.Scene(); //---------- // camera //---------- camera = new THREE.PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR); //camera.position.set(0,0,450); camera.position.set(0,150,300); //---------- // objects //---------- // create the video element video = document.createElement('video'); // video.id = 'video'; // video.type = ' video/ogg; codecs="theora, vorbis" '; video.src = 'data/sintel.ogv'; //video.src = 'data/az.mp4'; video.load(); // must call after setting/changing source video.play(); videoImage = document.createElement('canvas'); //videoImage.width = 480; //videoImage.height = 204; videoImageContext = videoImage.getContext('2d'); _imageWidth = videoImage.width; _imageHeight = videoImage.height; //videoImageContext.fillStyle = '#ffffff'; //videoImageContext.fillRect(0, 0, videoImage.width, videoImage.height); //---------- // controls //---------- controls = new THREE.OrbitControls(camera); //---------- // events //---------- window.addEventListener('resize', onWindowResize, false); //---------- // render //---------- var args = { //antialias: true // too slow } renderer = new THREE.WebGLRenderer(args); renderer.setClearColor(0x000000, 1); renderer.setPixelRatio(SCREEN_PIXEL_RATIO); //Set pixel aspect ratio renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT); // attach to dom container.appendChild(renderer.domElement); //render(); } function render() { if(video.readyState === video.HAVE_ENOUGH_DATA && !video.paused && !video.ended) // and video.currentTime > 0 { //_imageWidth = videoImage.width; //_imageHeight = videoImage.height; videoImageContext.drawImage(video,0,0,_imageWidth,_imageHeight); // Grab the pixel data from the backing canvas var _data = videoImageContext.getImageData(0,0,videoImage.width,videoImage.height).data; //log(data); //_pixels = data; var x = 0, y = 0; if(_lineGroup) { scene.remove(_lineGroup); //_lineGroup = null; } _lineGroup = new THREE.Object3D(); var _material = new THREE.LineBasicMaterial({ color: 0xffffff, linewidth: _guiOptions.lineThickness }); // loop through the image pixels for(y = 0; y < _imageHeight; y+= _guiOptions.scanStep) { var _geometry = new THREE.Geometry(); for(x=0; x<_imageWidth; x+=_guiOptions.scanStep) { var color = new THREE.Color(getColor(x, y, _data)); var brightness = getBrightness(color); var posn = new THREE.Vector3(x -_imageWidth/2,y - _imageHeight/2, -brightness * _guiOptions.depth + _guiOptions.depth/2); //_geometry.vertices.push(new THREE.Vertex(posn)); _geometry.vertices.push(posn); _geometry.colors.push(color); _color = null; _brightness = null; _posn = null; } // add a line var _line = new THREE.Line(_geometry, _material); //log(line); _lineGroup.add(_line); // gc _geometry = null; } scene.add(_lineGroup); _data = null; _line = null; } renderer.render(scene,camera); } function animate(){ requestAnimationFrame(animate); stats.update(); render(); } function onWindowResize(){ camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); render(); } // Returns a hexadecimal color for a given pixel in the pixel array. function getColor(x, y, _pixels) { var base = (Math.floor(y) * _imageWidth + Math.floor(x)) * 4; var c = { r: _pixels[base + 0], g: _pixels[base + 1], b: _pixels[base + 2], a: _pixels[base + 3] }; return (c.r << 16) + (c.g << 8) + c.b; } // return pixel brightness between 0 and 1 based on human perceptual bias function getBrightness(c) { return ( 0.34 * c.r + 0.5 * c.g + 0.16 * c.b ); } </script> 让git重新压缩其内容,但是这个命令应该偶尔由git运行一次。

  1. 我知道this post,它提供了一个脚本,让git列出其对象和大小,然后尝试给它们一个人名
  2. 这需要重写历史记录,因此请小心并警告其他开发人员,如果您的共享是共享的:您要查找的命令是git repack(使用git filter-branch选项)
  3. 您可以投放--index-filtergit gc。另一种方法是使用您的回购的新副本:

    git repack