I use(just use not develop) some other people's git repos, but I don't want the whole history.
It seemed that 'git clone --depth 1' meets my requirements.
But
1) how can I trim the existing repos like I do a 'git clone --depth 1' ?
2) how can I update the repo without history, so the repo only remain the last commit?
Assume the reop's history is A-B-C, I execute 'git clone --depth 1', so I get a repo of C. Then the upstream update the repo, the history become A-B-C-D-E. Can I do some simple operation, so I get a repo of E? Delete the repo and execute 'git clone --depth 1' again?
I want this, because some repo's history is too big, the .git maybe 100M+, and my internet access is not so stable, so I want the last update only.
Solution
1) make a existing repo shallow:
git rev-parse HEAD > .git/shallow
git reflog expire --all --expire=now
git gc --aggressive --prune=now
2) update a shallow repo:
git fetch origin master --depth=1
git reset --hard origin/master
after upate several times, you can:
git reflog expire --all --expire=now
git gc --aggressive --prune=now
to remove old commits and files again.
Referece