GIT: GIT Garbage Collection Refspecs & Reflog

GIT Garbage Collection

For large repositories, GIT will periodically perform a garbage collection to remove any unnecessary objects and compress refs(pointer to commits in GIT) into a single file for more efficient performance.

So the ref in .git\refs\branches will be moved a single file (i.e packaged-refs) after the command.

BTW… Git maintains information regarding the fetched branches, head, merge-head, etc in files in .git folder…

Again it is pointer having commit hash tag in it.

  • what the heck is Refspecs?

Same as Git Remote(It basically shorten the long remote urls to something of shorter name)

It basically maps the local repository to a remote repository however a bit different format.. Here is what git-scm.com says

 Suppose you add a remote like this:

$ git remote add origin https://github.com/schacon/simplegit-progit

It adds a section to your .git/config file, specifying the name of the remote (origin), the URL of the remote repository, and the refspec for fetching:

[remote "origin"]
	url = https://github.com/schacon/simplegit-progit
	fetch = +refs/heads/*:refs/remotes/origin/*

The format of the refspec is an optional +, followed by <src>:<dst>, where <src> is the pattern for references on the remote side and <dst> is where those references will be written locally. The + tells Git to update the reference even if it isn’t a fast-forward.

       With refspecs you tell git what to push/fetch where and how to map local refs to remote refs and vice     versa.

When you clone a repository git sets up the default refspec, you can see it in .git/config in the repository:

  • what the heck is Reflog?

It keeps the history of whatever you do in the repository in the chronological order.

Relative Refs

Leave a Reply

Your email address will not be published. Required fields are marked *