Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detach alternates after git clone --reference?

Tags:

git

clone

I'm using git clone --reference to reduce network traffic over a slow connection.

Now, git-clone's man page points out the dangers of using this and suggests git repack -a to break the link, which I'm doing immediately after the clone.

What I'd like to know is - after I've done the repack, is it then safe to just delete .git/objects/info/alternates or is there a proper git command to do this?

Thanks

like image 954
Steve Folly Avatar asked Feb 11 '10 22:02

Steve Folly


People also ask

What to do after cloning?

Create a new repository on GitHub. Clone your repository to your local computer. Modify files in your repository and track changes using commits with git. Push your changes back to GitHub.

Does git clone Get all branches?

While you can clone repositories with the git clone command, keep in mind that this clones the branch and the remote HEAD . This is usually master by default and includes all other branches in the repository. So when you clone a repository, you clone the master and all other branches.

What does git clone -- mirror do?

git clone --mirror In addition, --mirror will clone all the extended refs of the remote repository, and maintain remote branch tracking configuration. You can then run git remote update on the mirror and it will overwrite all refs from the origin repo.


2 Answers

Note that git clone now has a new --dissociate option that does this. It was added in Git 2.3: https://github.com/blog/1957-git-2-3-has-been-released

The option simply calls git repack -a -d and deletes .git/objects/info/alternates. So yes, it is safe. (Source: https://github.com/gitster/git/commit/d35c8027937546e6b22a2f28123f731c84e3b380)

like image 136
Tomi Avatar answered Sep 27 '22 21:09

Tomi


OK, so I found out. The answer is yes, it is safe to delete alternates directly. And no, there is no git command to do this.

http://thread.gmane.org/gmane.comp.version-control.git/141161/focus=141199

I know it's not the done thing to answer your own question, but we have to move on!

like image 37
Steve Folly Avatar answered Sep 27 '22 23:09

Steve Folly