I have huge size of git repo in my local system with 10 different branches, In those 10 branch the master repository is around 2 GB. when i switch from any branch1 to master branch, Git is trying to checkout all files in local system itself, how to reduce the time here.
[linux@linux_001 myrepo]$ time git checkout master
Checking out files: 100% (25765/25765), done.
Switched to branch 'master'
real 0m55.617s
user 0m35.597s
sys 0m5.002s
Here i have reduce 55 sec
One workaround would be to use the
git worktreecommand: you can clone a repo once, but check it out in multiple folders, one per branch.That way, instead of changing your current worktree, you can simply change folder to the one where
masteris already checked out) and update its content with agit pull(incremental update, much faster)That seems easier than trying to put in place a sparse checkout or a shallow clone.