You are viewing a single thread.
View all comments View context
43 points

No, don’t do that. That modifies the commit hashes, so tags no longer work.

git clone --filter=blob:none is where it’s at.

permalink
report
parent
reply
18 points
*

I don’t understand how we’re all using git and it’s not just some backend utility that we all use a sane wrapper for instead.

Everytime you want to do anything with git it’s a weird series or arcane nonsense commands and then someone cuts in saying “oh yeah but that will destroy x y and z, you have to use this other arcane nonsense command that also sounds nothing like you’re trying to do” and you sit there having no idea why either of them even kind of accomplish what you want.

permalink
report
parent
reply
21 points

It’s because git is a complex tool to solve complex problems. If you’re one hacker working alone, RCS will do an acceptable job. As soon as you add a second hacker, things change and RCS will quickly show its limitations. FOSS version control went through CVS and SVN before finally arriving at git, and there are good reasons we made each of those transitions. For that matter, CVS and SVN had plenty of arcane stuff to fix weird scenarios, too, and in my subjective experience, git doesn’t pile on appreciably more.

You think deleting an empty directory should be easy? CVS laughs at your effort, puny developer.

permalink
report
parent
reply
1 point
*

It’s because git is a complex tool to solve complex problems. If you’re one hacker working alone, RCS will do an acceptable job. As soon as you add a second hacker, things change and RCS will quickly show its limitations. FOSS version control went through CVS and SVN before finally arriving at git, and there are good reasons we made each of those transitions. For that matter, CVS and SVN had plenty of arcane stuff to fix weird scenarios, too, and in my subjective experience, git doesn’t pile on appreciably more.

Yes it is a complex tool that can solve complex problems, but me as a typical developer, I am not doing anything complex with it, and the CLI surface area that’s exposed to me is by and large nonsense and does not meet me where I’m at or with the commands or naming I would expect.

I mean NPM is also a complex tool, but the CLI surface area of NPM is “npm install”.

permalink
report
parent
reply
9 points

There are tons of wrappers for git, but they all kinda suck. They either don’t let you do something the cli does, so you have to resort to the arcane magicks every now and then anyways. Or they just obfuscate things to the point where you have no idea what it’s doing, making it impossible to know how to fix things if (when) it fucks things up.

permalink
report
parent
reply
6 points

Git is complicated, but then again, it’s a tool with a lot of options. Could it be nicer and less abstract in its use? Sure!

However, if you compare what goes does, and how it does, to it’s competitors, then git is quite amazing. 5-10 years ago it was all svn, the dark times. Simpler tool and an actual headache to use.

permalink
report
parent
reply
2 points

Mercurial is way better.

There, I said it.

permalink
report
parent
reply
1 point

I think in this case, “depth” was am inferior solution to achieve fast cloning, that they could quickly implement. Sparse checkout (“filter”) is the good solution that only came out recently-ish

permalink
report
parent
reply
0 points

You are not entirely wrong, but just as some advice I would refrain from displaying fear of the command line in interviews.

permalink
report
parent
reply
3 points
*

Lol if an employer can’t have an intelligent discussion about user friendly interface design I’m happy to not work for them.

Every interview I’ve ever been in there’s been some moment where I say ‘yeah I don’t remember that specific command, but conceptually you need to do this and that, if you want I can look up the command’ and they always say something along the lines of ‘oh no, yeah, that makes conceptual sense don’t worry about it, this isn’t a memory test’.

permalink
report
parent
reply
7 points

Thanks, didn’t know about that one.

permalink
report
parent
reply
5 points
*

What are you smoking? Shallow clones don’t modify commit hashes.

The only thing that you lose is history, but that usually isn’t a big deal.

--filter=blob:none probably also won’t help too much here since the problem with node_modules is more about millions of individual files rather than large files (although both can be annoying).

permalink
report
parent
reply
1 point

From github’s blog:

git clone --depth=1 <url> creates a shallow clone. These clones truncate the commit history to reduce the clone size. This creates some unexpected behavior issues, limiting which Git commands are possible. These clones also put undue stress on later fetches, so they are strongly discouraged for developer use. They are helpful for some build environments where the repository will be deleted after a single build.

Maybe the hashes aren’t different, but the important part is that comparisons beyond the fetched depth don’t work: git can’t know if a shallowly cloned repo has a common ancestor with some given commit outside the range, e.g. a tag.

Blobless clones don’t have that limitation. Git will download a hash+path for each file, but it won’t download the contents, so it still takes much less space and time.

If you want to skip all file data without any limitations, you can do git clone --filter=tree:0 which doesn’t even download the metadata

permalink
report
parent
reply
2 points

Yes, if you ask about a tag on a commit that you don’t have git won’t know about it. You would need to download that history. You also can’t in general say “commit A doesn’t contain commit B” as you don’t know all of the parents.

You are completely right that --depth=1 will omit some data. That is sort of the point but it does have some downsides. Filters also omit some data but often the data will be fetched on demand which can be useful. (But will also cause other issues like blame taking ridiculous amounts of time.)

Neither option is wrong, they just have different tradeoffs.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 6.1K

    Monthly active users

  • 988

    Posts

  • 38K

    Comments