Here's the scenario: At work we have quite a few branches and we haven't kept the repo as tidy as we should, occasionally adding/removing large files or whatnot, and rarely removing dead branches.
So today is a snow day and I have to work from home. I have a slow VPN connection, and all I need is the fastest way to get to the one branch I care about and start working, with the ability to push commits back.
In SVN, I would have just updated the paths/files I needed and would have been working in no time. Like most git newbies, I only have a handful of trusted commands, and my fallback git clone or git pull are going to be too slow.
So it seems to be a two part question:
- How do I clone a repo to get working as quickly as possible, and
- How do I pull/push from this repo (edit, commit, pull, push)
Working solution (per @g19fanatic's suggestions below):
> git clone -b <branchname> <repo_url> --depth=1
remote: Counting objects: 16679, done.
remote: Compressing objects: 100% (11926/11926), done.
remote: Total 16679 (delta 6936), reused 10919 (delta 3337)
Receiving objects: 100% (16679/16679), 628.12 MiB | 430 KiB/s, done.
Resolving deltas: 100% (6936/6936), done.
> git pull
Already up-to-date.
(make small change on other machine, commit/push)
> git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Excellent, this left me with a working repo.
The only issue is that it transferred twice as much data initially as the below failed attempts did, but it did leave the repo in a usable state. I'll considered this answered, but I think there could be improvement on the initial transfer size.