2016-03-04 166 views
0

這裏面有個Rails應用程序的目錄的相應尺寸,我繼承:如何壓縮.git目錄中的git

→ find . -maxdepth 1 -type d -mindepth 1 -exec du -hs {} \; 
263M ./.git 
2.0M ./app 
124K ./config 
728K ./db 
4.0K ./doc 
56K ./lib 
    0B ./log 
232K ./public 
8.0K ./script 
164K ./spec 
560K ./spreadsheets 
16K ./test 
64K ./vendor 

我在Github上做了一個新的存儲庫關閉現有資源庫分支,離開舊的一個完好無損。 由於舊存儲庫的特定分支成爲新存儲庫的主分區,並且這是新存儲庫中的唯一分支,因此我不需要任何新存儲庫中的歷史記錄。我希望將.git的大小設置爲最小大小,因爲這對Github空間,本地空間和Heroku部署來說是絕對浪費的。

Git init沒有工作。我不知道我是否可以只是

rm -rf .git 

然後重新初始化git存儲庫,然後將其推送到Github遠程。

+0

如果您不需要任何歷史,然後通過刪除'.git'文件夾復位Git和發出'git init'。 –

回答

0

執行以下命令:

# remove old content 
rm -rf .git 

# init new repo 
git init 

# add all current files (add .gitignore entries if you need to ignore some files) 
git add -A . 

# commit the current content 
git commit - m ".. Message..." 

# add the remote url of the github server 
git remote add origin <github new url> 

# oush your code to github 
git push origin master 
+0

謝謝你們,那就是我所做的。作品。 – Bharat