From: Mateusz Loskot <mateusz@loskot.net>
To: git@vger.kernel.org
Subject: Checkout branch and prune everything related to previous checkout (incl. LFS remains)
Date: Sun, 27 Jan 2019 01:16:17 +0100 [thread overview]
Message-ID: <CABUeae_tm__uvHH74UARG805uTa2Sf0v6wYk=pmKvxxH3kvQ8A@mail.gmail.com> (raw)
Hi,
I have a repo of a superproject with number of submodules.
lots of files of both are in Git LFS.
The repo comes with multiple long-lived release branches.
The complete clone transfers 20 GB of Git and Git LFS objects.
Checkout of master deflates the total repo to 40 GB in total,
that is the objects and the working tree files together.
Let's consider three separate clones as canonical way to create
three working copies, one per the long-lived branch:
```
git clone --branch master --recursive --jobs 8 https://repo repo_master
git clone --branch release/1.0 --recursive --jobs 8 https://repo repo_release1
git clone --branch release/2.0 --recursive --jobs 8 https://repo repo_release2
```
I'm trying to work out a network-optimised equivalent of the above:
- clone once with the default master checked out
- make multiple copies of the cloned repo
- checkout release branches
How to checkout an existing branch fetched from remote,
delete the previous branch and clean up any remains?
How to clean up everything related to the previously checked out
master and its working tree, any cached previous LFS downloads etc.?
But, to keep the history of origin/master.
Here is what I have come up with for the the network-optimised workflow:
```
git clone --branch master --recursive --jobs 8 https://repo repo_master
cp -a repo_master repo_release1
cp -a repo_master repo_release2
cd repo_release1
git checkout -b release/1.0 --track origin/release/1.0
git pull
git submodule update --init --recursive --jobs 8
git branch -D master
git lfs prune
git submodule foreach --recursive git lfs prune
git lfs checkout
git submodule foreach --recursive git lfs checkout
```
Does it look correct or any steps are missing/redundant?
Does it make sense to run any of these, at which point?
git gc --aggressive --prune=now
git submodule foreach --recursive git gc --aggressive --prune=now
Please, assume, no new commits will happen locally between the
`git clone --branch master ...` and `cp -a repo_master ...`.
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
reply other threads:[~2019-01-27 0:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABUeae_tm__uvHH74UARG805uTa2Sf0v6wYk=pmKvxxH3kvQ8A@mail.gmail.com' \
--to=mateusz@loskot.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).