Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Team Foundation Server 2015 (tfs2015) run git gc --prune=now on orgin/remote

Is there a way to run git gc --prune=now on remote Team Foundation Server 2015 (tfs2015)? Or is the only way to run git gc --prune=now locally then create new repository on tfs2015 and push it to new remote, then delete the old repository, and rename new repository to old name. Don't forget to turn off the liking commit when doing that.

like image 912
Janusz Nowak Avatar asked Aug 28 '15 18:08

Janusz Nowak


2 Answers

See https://blogs.msdn.microsoft.com/congyiw/2015/12/14/why-does-cloning-from-vsts-return-old-unreferenced-objects/ - this is a known limitation of TFS-hosted git, it doesn't have the gc command.

Microsoft provides two workarounds:

  • clone the repo, clean it locally, delete it from the server, create a new one and push your cleaned one to it (what you described in your question)
  • don't git clone, but obtain your local repo like this:

    mkdir newRepo
    git init
    git remote add origin 
    #fetch one branch first
    git fetch origin master
    #fetch everything else
    git fetch origin
    

    which tricks TFS to actually send you only the objects you really need.

Option 1 seems to be more reasonable to me if you can afford losing your pull requests etc (e.g. if this is a relatively new repo).

Option 2 feels really bad, as any user of the repo will have to manually create their clone this way.

like image 112
Jakub Januszkiewicz Avatar answered Oct 06 '22 12:10

Jakub Januszkiewicz


Update about comming this in TFS v.Next And all ready rolled out in VSTS https://blogs.msdn.microsoft.com/congyiw/2015/12/14/why-does-cloning-from-vsts-return-old-unreferenced-objects/ "UPDATE (2017-08-09): We rolled out commit reachability bitmap indexes to VSTS and removed the clone cheat mentioned below. Cloning will no longer download unreachable objects!. We still don't have true object-level git gc on the server yet, but clone sizes will be smaller now.

TFS on-prem will get these changes in v.Next (not in any TFS 2017 updates, but the next major release). As Brian Harry mentioned, we should have a release candidate for v.Next in a few weeks."

like image 23
Janusz Nowak Avatar answered Oct 06 '22 12:10

Janusz Nowak