Live data from Hacker News

What is in that .git directory?

blog.meain.io

31–40 of 47 posts

Re: What is in that .git directory?

#31

Earlier quoted context omitted.

Thanks! Yeah I plan to get to the bottom of it. I will probably propose to just keep a branch with full history somewhere (we need to keep history for auditability) and reset the main branch from a recent state.

I can recommend git-filter-repo instead, it's relatively recent and there is a lot of outdated info on the internet about cleaning git repos. The --analyse flag will generate a report about files in your repo even if they were deleted. I used it to cleanup a number of repo and it helped in detecting large files commited by mistake 10 years ago. The history rewrite removed the files and we didn't need to create a new…

This looks like a great tool. I'm not sure if I haven't come across it before or I'd forgotten about it.

In my experience you'll have references to the commits in a repo from outside of the repo: links from Slack, Jira, other repos, etc to specific commit IDs. When you rewrite history, all of the commit IDs change. That's why I recommend archiving the original repo so as not to break any such references. Create the new repo, either rewritten or seeded from the old, in a new location.

It would be neat if git supported a "rewite map" to allow it to redirect from one revision to another, sort of like how `git blame` can be configured to ignore revisions.

Re: What is in that .git directory?

#32
post #29

just a random comment: the .git/info/exclude file acts as a personal, private .gitignore you don't have to commit

Nice! I didnt know about this. Feel like its in an odd place. This is the first ive ever heard of this, so must be that not many use it (or admit to using it)

Re: What is in that .git directory?

#33
post #29

just a random comment: the .git/info/exclude file acts as a personal, private .gitignore you don't have to commit

Nice! I didnt know about this. Feel like its in an odd place. This is the first ive ever heard of this, so must be that not many use it (or admit to using it)

A more suggestive name like “private-ignore” would help.

Re: What is in that .git directory?

#36
post #2

If you'd like a more in-depth treatment of the topic, let me suggest chapter 10 of the git book: https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Po... > But what gets sent to the other git repo? It is everything that is in objects and under refs. Not everything under refs. Just the refs that you push. What gets pushed depends on how you configure git, what arguments you provide to `git push` and how the ref…

> Not everything under refs. Just the refs that you push.

Ahh, thanks. I overlooked that detail. I've fixed it now. :D

Re: What is in that .git directory?

#38

By random chance I ended up in the git internals doc^1 today, also lovely refered to as plumbing and porcelain. It's a fantastic read, very well explained. I wish all doc was written with such explicit care to be understood. It reads like a good friend is trying to explain you something. What got me into that was a 51Gb ".pack" file that I wanted to understand. If you wonder about that, they're pack files, and what t…

I'm doing analysis with git-filter-repo --analyze

I've found 1gb files in our repository (thankfully a work in progress so we're able to remove it before it goes to main).

It lists everything by size.

Re: What is in that .git directory?

#39

By random chance I ended up in the git internals doc^1 today, also lovely refered to as plumbing and porcelain. It's a fantastic read, very well explained. I wish all doc was written with such explicit care to be understood. It reads like a good friend is trying to explain you something. What got me into that was a 51Gb ".pack" file that I wanted to understand. If you wonder about that, they're pack files, and what t…

RE large pack files: you can remove unused objects with these commands:

git repack -AFd

git prune --expire now

Also related, the initial git clone from a TFS server (as of 2015) can include every object ever pushed to the server, even if it is on no current branch. So the above commands might save significant space locally. I’m not if newer versions of TFS and DevOps improved this behavior.

Re: What is in that .git directory?

#40

By random chance I ended up in the git internals doc^1 today, also lovely refered to as plumbing and porcelain. It's a fantastic read, very well explained. I wish all doc was written with such explicit care to be understood. It reads like a good friend is trying to explain you something. What got me into that was a 51Gb ".pack" file that I wanted to understand. If you wonder about that, they're pack files, and what t…

> I wish all doc was written with such explicit care to be understood. It reads like a good friend is trying to explain you something.

Thanks for this insight. As a technical writer this is a helpful phrase for providing guidelines on how to write docs.

Post reply on HN