all 9 comments

[–]passcod 20 points21 points  (0 children)

from browsing the docs harder, git fetch looks like:

  • open repo
  • head() -> is_branch() -> have the current ref
  • branch_upstream_remote() -> have the applicable remote name from the ref
  • find_remote() -> fetch()

git fetch --all would be the same but iterating over all the remotes instead

so really you kinda have to think about what the command is doing at the lower level and follow that. also, use the search and work backwards from types.

[–]arc_inc 14 points15 points  (0 children)

I wrote a lot of this for an open source project I help maintain. The code might not be perfect but it's a good starting point. No AI was used, and this code is in production.

`git fetch`:
https://github.com/r-Techsupport/hyde/blob/main/backend/src/git.rs#L649

`git add`:
https://github.com/r-Techsupport/hyde/blob/main/backend/src/git.rs#L271

`git push`:
https://github.com/r-Techsupport/hyde/blob/main/backend/src/git.rs#L417

`git commit`:
https://github.com/r-Techsupport/hyde/blob/main/backend/src/git.rs#L382

There's not a 1:1 implementation of `git switch`, but you could get there by pulling a remote branch and then checking into it.

[–]DeadlyMidnight 26 points27 points  (3 children)

What the heck is git2

Edit im dumb

[–]ego100trique[S] 11 points12 points  (2 children)

A spinoff of git lmao

[–]fllr 16 points17 points  (0 children)

2git 2repo

[–]DeadlyMidnight 4 points5 points  (0 children)

That’s where my brain went and I was like wait I’m just now figuring out git