14 ms·
You already have a Git server
- thyristan 1y agoMaybe I'm too old, but are there people that really didn't know that any ssh access is sufficient for using git?
- liveoneggs 1y agomost people think git = github
- halJordan 1y agoI always found these sort of categorical denigrations to be off base. If most people do think git = github then that's because they were taught it by somebody. A lot of somebodies for "most people". Likely by the same somebodies who also come to places like this. It has always taken a village to raise a child and that is just as true for an infant as a junior programmer. But instead we live in a sad world of "why didn't schools teach person x"
- bfkwlfkjf 1y ago[flagged]
- blueflow 1y agoHumans are fallible, relying on hearsay is unprofessional, learn your craft properly. Imagine what the equivalent argumentation for a lawyer or nurse would be. Those rules ought to apply for engineers, too.
- loloquwowndueo 1y agoDespite your indignation, the observation that most people think GitHub is git is entirely true. Do you point it out when you spot someone having that mistaken belief? I do.
- liveoneggs 1y agothey were taught by github
- Dylan16807 1y agoWhat makes you say that people complain about the spread of incorrect knowledge "instead" of teaching? Because there's nothing wrong with doing both.
- albert_e 1y agoIT support and cybersecurity teams responsible for blocking and enforcing network access restriction to "github.com" ... blocked a user request to install "git" locally citing the former policy. The organization in question does IT services, software development, and maintenance as their main business.
- jiggawatts 1y agoThat’s… special.
- watwut 1y agoSometimes I feel like IT and security people compete on how to make the work least possible. These guys won.
- bfkwlfkjf 1y agoNonsense... Even someone who knows that git isn't GitHub might not be aware that ssh is enough to use git remotely. That's actually the case for me! I'm a HUGE fan of git, I mildly dislike GitHub, and I never knew that ssh was enough to push to a remote repo. Like, how does it even work, I don't need a server? I suspect this is due to my poor understanding of ssh, not my poor understand of git.
- porridgeraisin 1y ago> I don't need a server? You do, an SSH server needs to be running on the remote if you want to ssh into it, using your ssh client - the `ssh` command on your laptop. It's just not a http server is all. You start that server using the `sshd` [systemd] service. On VPSs it's enabled by default. Git supports both http and ssh as the "transport method". So, you can use either. Browsers OTOH only support http.
- bfkwlfkjf 1y agoExactly! Only now the dots connected. Thank you!! Edit: hey this is really exciting. For a long time one of the reasons I've loved git (not GitHub) is the elegance of being a piece of software which is decentralized and actually works well. But I'd never actually used the decentralized aspect of it, I've always had a local repo and then defaulted to use GitHub, bitbucket or whatever instead, because I always thought I'd need to install some "git daemon" in order to achieve this and I couldn't be bothered. But now, this is so much more powerful. Linus Torvalds best programmer alive, change my mind.
- Dylan16807 1y agoAnd in general, any daemon that manipulates files can be replaced by ssh (or ftp) access and a local program. And most things are files.
- tsimionescu 1y agoBTW, a nice example of this general concept is Emacs' TRAMP mode. This is a mode where you can open and manipulate files (and other things) on remote systems simply by typing a remote path in Emacs. Emacs will then simply run ssh/scp to expose or modify the contents of those files, and of course to run any required commands, such as deleting a file.
- setopt 1y agoYup. I’ve heard several people say that Git is a product from Microsoft…
- devsda 1y agoI wouldn't mind it if those people are from non-tech background. Now, if it is a growing misconception among cs students or anyone doing software development or operations, that's a cause for concern.
- littlecranky67 1y agoThe irony, when you realize that Linus Torvalds created git.
- mrweasel 1y agoThere's an interview with Torvalds where he states that his daughter told him that in the computer lab at her college Linus is more known for Git than Linux Clip from the interview: https://www.youtube.com/shorts/0wLidyXzFk8 https://www.youtube.com/shorts/0wLidyXzFk8
- ruguo 1y agoLooks like they’re not developers after all
- brucehoult 1y agoOr just put the repo in a shared directory in a high-trust group of developers (or just yourself).
- ryandv 1y agoFilesystems and folders are foreign and elusive concepts to gen Z. https://www.theverge.com/22684730/students-file-folder-directory-structure-education-gen-z https://www.theverge.com/22684730/students-file-folder-direc...
- liveoneggs 1y agoI have encountered it in real life many times. These days I try to give jr's extra space to expose their gaps in things I previously assumed were baseline fundamentals - directories and files, tgz/zip files, etc
- andai 1y agoIt gets better than that... https://www.youtube.com/shorts/D1dv39-ekBM https://www.youtube.com/shorts/D1dv39-ekBM
- deleted 1y ago[deleted]
- Izkata 1y agoA tip, you can put the hash in a regular youtube URL to get the full interface instead of the limited shorts one: https://www.youtube.com/watch?v=D1dv39-ekBM https://www.youtube.com/watch?v=D1dv39-ekBM
- andai 1y agoThanks. You can also replace /shorts/ with /watch/ and get the same result. https://youtube.com/watch/D1dv39-ekBM https://youtube.com/watch/D1dv39-ekBM
- politelemon 1y agoAlso relatively unknown: You can clone from a directory. It won't accomplish the backup feature but it's another option/feature.
- deleted 1y ago[deleted]
- deleted 1y ago[deleted]
- superdisk 1y agoIf you do it over NFS or whatever then you can collaborate as well.
- mvanbaak 1y agogit over nfs ... not the very best idea.
- kragen 1y agoI haven't tried it, but I think it's fine if only one person has write access to any given clone. You can pull back and forth between clones freely. It's if you have two Git clients trying to write to the same repo that you'll have problems.
- kbolino 1y agoShared write access to the same git repo directory can be done sanely, but you have to get a number of things right (same group for all users, everything group writable, sticky bit on directories, set config core.sharedRepository=group): https://stackoverflow.com/a/29646155 https://stackoverflow.com/a/29646155
- kragen 1y agoYes, when you're not on NFS. Maybe it works on NFS but I wouldn't bet my project on it. Locking reliably on NFS is easy to get wrong, and it's a comparatively little-tested scenario now compared to 30 years ago. (You'll notice that the question doesn't even mention the possibility of NFS.) Fortunately at least with Git it's easy to have lots of backups.
- torben-friis 1y agoI didn’t know either - or rather, I had never stopped to consider what a server needs to do to expose a git repo. But more importantly, I’m not sure why I would want to deploy something by pushing changes to the server. In my mental model the repo contains the SOT, and whatever’s running on the server is ephemeral, so I don’t want to mix those two things. I guess it’s more comfortable than scp-ing individual files for a hotfix, but how does this beat pushing to the SOT, sshing into the server and pulling changes from there?
- skydhash 1y agoThere's a lot of configuration possible due to the fact that git is decentralized. I have a copy on my computer which is where I do work. Another on a vps for backup. Then one on the app server which only tracks the `prod` branch. The latter is actually bare, but there's a worktree for the app itself. The worktree is updated via a post-receive hook and I deploy change via a simple `git push server prod`
- torben-friis 1y agoYou actually led me into a dive to learn what worktrees are, how bare repos + worktrees behave differently from a regular clone and how a repo behaves when it’s at the receiving end of a push, so thanks for that! I’ve never worked with decentralized repos, patches and the like. I think it’s a good moment to grab a book and relearn git beyond shallow usage - and I suspect its interface is a bit too leaky to grok it without understanding the way it works under the hood.
- t_mahmood 1y agoMy way used to be in the past, put bare repos on Dropbox, clone the bare repo to a real path. Done. That way, I 1. didn't have to worry about sync conflicts. Once complete, just push to origin 2. had my code backed up outside my computer I can't exactly remember, if it saves space. I assumed it does, but not sure anymore. But I feel it was quite reliable. I gave that way up with GitHub. But thinking of migrating to `Codeberg` With `tailscale`, I feel we have so much options now, instead of putting our personal computer out on the Internet.
- crazygringo 1y agoThat doesn't work -- I've tried it. I mean, it works fine for a few days or weeks, but then it gets corrupted. Doesn't matter if you use Dropbox, Google Drive, OneDrive, whatever. It's apparently something to do with the many hundreds of file operations git does in a basic operation, and somehow none of the sync implementations can quite handle it all 100.0000% correctly. I'm personally mystified as to why not, but can attest from personal experience (as many people can) that it will get corrupted. I've heard theories that somehow the file operations get applied out of order somewhere in the pipeline.
- kragen 1y agoI've had a lot of success with using whatever. A lot of whatevers can quite handle many hundreds of file operations 100.0000% correctly.
- crazygringo 1y agoHa. I guess for me the other whatever is iCloud, but that corrupts too. But have you ever found a cloud sync tool that doesn't eventually corrupt with git? I'm not aware of one existing, and I've looked. Again, to be clear, I'm not talking about the occasional rsync, but rather an always-on tool that tries to sync changes as they happen.
- kragen 1y ago
- candiddevmike 1y agoWhat are some fun/creative ways to do GitHub/GitLab style CI/CD with this method? Some kind of entry point script on push that determines what to do next? How could you decide some kind of variables like what the push was for?
- deleted 1y ago[deleted]
- yule 1y agoI wrote about that idea here: https://www.stchris.net/tiny-ci-system.html https://www.stchris.net/tiny-ci-system.html
- skydhash 1y ago`man 5 githooks` is your friend. Hooks are just scripts and they can receive parameters. `post-receive` is most likely what you would want.
- CGamesPlay 1y agoCheck the docs for the post-receive hook, it does give everything you need. I don't know what you have in mind by "GitHub/Gitlab style", but it's just a shell script, and you can add in as much yaml as you want to feel good about it. I did a quick search for "post-receive hook ci" and found this one: https://gist.github.com/nonbeing/f3441c96d8577a734fa240039b7113db https://gist.github.com/nonbeing/f3441c96d8577a734fa240039b7...
- bluedino 1y agoConsidering git is one of those things barely anyone knows how to actually use, yes
- seba_dos1 1y agoMy theory is that git is just so easy to use without understanding it that you end up with lots of people using it without understanding it :)
- BoiledCabbage 1y agoIt's not "so easy to use without understanding it", it's the opposite it has so much unnecessary complexity (on top of a brilliant simple idea btw), that once people learn how to do what they need, they stop trying to learn any more from the pile of weirdness that is git. Decades from now, git will be looked back at in a similar but worse version of the way SQL often is -- a terrible interface over a wonderful idea.
- seba_dos1 1y agoI don't think that's true. In my experience it takes time, but once it clicks, it clicks. Sure, there is a bunch of weirdness in there as well, but that starts way further than where your typical git user stops. I don't think git would end up this popular if it didn't allow to be used in a basic way by just memorizing a few commands without having to understand its repository model (however simple) well.
- isodev 1y agoI imagine larger part of the developer community does not, in fact, know that GitHub is not git and one can get everything they need without feeding their code to Microsoft's AI empire. Just another "Embrace, extend, and extinguish"
- tuwtuwtuwtuw 1y agoI would be surprised if more than 10% of git users know that. Would be equally surprised if more than 20% of git users know how to use ssh. I think your age isn't the issue, but I suspect you're in a bubble.
- kleiba 1y agoThe non-Windows bubble?
- dtgriscom 1y agoI actually realized this last week, and have yet to try it. Programming for almost fifty years, using Git for thirteen years, and not an idiot (although there are those who would dispute this, including at times my spouse).
- __MatrixMan__ 1y agoI've been using git since 2007, this only dawned on me last year. Git is especially prone to the sort of confusion where all the experts you know use it in slightly different ways so the culture is to just wing it until you're your own unique kind of wizard who can't tie his shoes because he favors sandals anyhow.
- skydhash 1y agoThe Pro Git book is available online for free https://git-scm.com/book/en/v2 https://git-scm.com/book/en/v2
- kevmo314 1y agoThis sort of thing is part of the problem. If it takes reading such a long manual to understand how to properly use Git, it's no wonder everyone's workflow is different.
- PaulDavisThe1st 1y agoDo you know any construction folks?
- kragen 1y agoI don't see it as a problem that everyone's workflow is different, and, separately, I don't see it as a problem that it takes reading such a long manual to understand all the possibilities of Git. There is no royal road to geometry. Pro Git is a lot shorter than the textbook I learned calculus from. Unlike calculus, though, you can learn enough about Git to use it usefully in ten minutes. Maybe this sets people up for disappointment when they find out that afterwards their progress isn't that fast.
- __MatrixMan__ 1y agoAgreed. I'd read the manual if there was something I needed from it, but everything is working fine. Yeah I might've rsynced between some local folders once or twice when I could've used git, maybe that was an inelegant approach, but the marginal cost of that blunder was... about as much time I've spent in this thread so whatever.
- thwarted 1y agoYes. I've been subject to claims that a single person can't start a project unless and until an official, centralized repo is setup for them. I've responded with "git init is all that is necessary to get started", but they wouldn't hear it.
- fingerlocks 1y agoYou must work at Microsoft? A pound of paperwork for every new repo really shuts down experimental side projects. I showed my colleagues that we can share code via ssh or (painfully) one-drive anytime instead. They reacted like I was asking them to smoke crack behind the dumpsters. “That’s dangerous, gonna get in trouble, no way bro”
- mewpmewp2 1y agoIf you are working in a large corp and not your own side project, that honestly does sound like a bad idea.
- deleted 1y ago[deleted]
- fingerlocks 1y agoPlease, elaborate. I can share my screen with coworkers and talk about all sorts of confidential things, and I can even give them full remote access to control everything if I wished. So why would pushing a some plain text code directly to their machine be so fundamentally different than all the other means of passing bits between our machines?
- mewpmewp2 1y agoIf you share screen you are in control of what you show, if you give someone SSH access, what would stop them from passing/running a small script to fetch everything you have or doing w/e with your computer? I mean it's a blatant security violation to me. Just no reason to do that. In large corps you usually have policies to not leave your laptop unattended logged in, in the office, that would be potentially even worse than that.
- victorbjorklund 1y agoI never thought about it. If somebody had asked me, yeah. Of course it makes sense. But it's just one of those things where I haven't thought about possibility.
- mewpmewp2 1y agoDepends on what you mean by using etc. If somebody asked me if it's possible to scp my git repo over to another box and use it there or vice versa, I would have said, yes, that is possible. Although I would've felt uneasy doing that. If somebody asked me if git clone ssh:// ... would definitely work, I wouldn't have known out of the gate, although I would have thought it would be neat if it did and maybe it does. I may have thought that maybe there must be some sort of git server process running that would handle it, although it's plausible that it would be possible to just do a script that would handle it from the client side. And finally, I would've never thought really to necessarily try it out like that, since I've always been using Github, Bitbucket, etc. I have thought of those as permanent, while any boxes I have could be temporary, so not a place where I'd want to store something as important to be under source control.
- Klonoar 1y agoAm I misreading your comment? You’ve always used GitHub but never known it could work over ssh? Isn’t it the default method of cloning when you’re signed in and working on your own repository…?
- deleted 1y ago[deleted]
- mewpmewp2 1y agoI have used SSH for GitHub of course, but the thought that I could also use it from any random machine to machine never occurred to me. And when it might occur to me, I would have thought that maybe SSH is used as a mechanism for authentication, but it might still require some further specialized server due to some unknown protocols of mine. I always thought of SSH or HTTPS as means of authentication and talking to the git server rather than the thing that processes cloning. E.g. maybe the host would have to have something like apt install git-server installed there for it to work. Maybe it wouldn't be available by default. I do know however that all info required for git in general is available in the directory itself.
- 1y ago
- dogleash 1y agoThere's definitely generational loss about the capabilities of git. In the beginning, git was a new version control option for people to explore, now git is the thing you learn to collaborate on github/lab/ea. I remember the Chagon book coming out as the peak between dense technical explainers and paint by numbers how-tos.
- thaumasiotes 1y agoI was aware that it should be possible to interact directly with another repository on another machine (or, heck, in another directory on the same machine), which implies that ssh access is sufficient, but I was unaware of how that would be done.
- nmz 1y agoI don't think it has anything to do with being old, this is what happens when your software gets too complex that nobody even knows the very basics. This is highlighted with the documentation, if the software's documentation becomes lengthy enough that it could be an entire book, you're going to be getting these sorts of articles from time to time. Another highlight is bash, that is a huge man page for what should be a shell.
- paradox460 1y agoIn the past I've blown coworkers minds during github outages when I just pulled code from a co-worker's machine and kept working With remote, if your company stubbornly refuses to use a modern vpn like tailscale, and you can't really network between two computers easily, git format patch and git am, coupled with something like slack messages, works well enough, albeit moderately cumbersome
- tom_ 1y agoYep, me. I noticed that you sometimes use ssh:// URLs for GitHub, but I figured it was for authentication purposes only, and that once that step was over, some other thing came into play.
- djoanwnn 1y agoIt usually is. Normally you don't put a full shell behind ssh if you only expose git, but of cause you can
- al_borland 1y agoI read an article not long ago where students coming out of a web dev bootcamp were unable to make a hello world html file and open it in their browser. We’ve gone so far with elaborate environments and sets to make it easy to learn more advanced things, that many people never learn the very basics. I see this as a real problem.
- UK-Al05 1y agoWith cors this can be awkward now.
- al_borland 1y agoFor a simple hello world HTML file, cors should not enter the equation.
- delta2uk 1y agoI think if you're too young to know the earlier alternatives it's easy to overlook the distributed nature of git which made it different from them.
- nicce 1y agoInteresting. I am just trying to decide between self-hosting Forgejo and other options for hosting Git in own private network.
- omani 1y agoam using gitea. but thinking of switching to serve (charm).
- icy 1y agoCould also consider running a Tangled knot (lightweight, headless git servers): https://tangled.org https://tangled.org
- rustman123 1y agoDoes this support private repositories with collaboration?
- icy 1y agoNot yet, unfortunately. Mostly due to protocol limitations—we use AT (https://atproto.com https://atproto.com) for federation.
- xeonmc 1y agocan tangled support a forum-styled or subreddit-like thread discussion interface, on a per-repo basis so that "anyone could start a subreddit" via creating a discussion-only repo?
- singpolyma3 1y agoOne note, xcode and maybe some other clients can't use http "dumb mode". Smart mode is not hard to set up, but it's a few lines of server config more than this hook. TIL about the update options for checked out branch. In practise though usually you want just the .git "bare" folder on server
- imiric 1y agoI've used Git over SSH for several years for personal projects. It just works with no additional overhead or maintenance. Tip: create a `git` user on the server and set its shell to `git-shell`. E.g.: sudo useradd -m -g git -d /home/git -s /usr/bin/git-shell git You might also want to restrict its directory and command access in the sshd config for extra security. Then, when you need to create a new repository you run: sudo -u git git init --bare --initial-branch=main /home/git/myrepo.git And use it like so: git clone git@myserver:myrepo.git Or: git remote add myserver git@myserver:myrepo.git git push -u myserver main This has the exact same UX as any code forge. I think that initializing a bare repository avoids the workarounds for pushing to a currently checked out branch.
- general1465 1y agoYes exactly, creating git user on Linux machine and configuring it just for git turned out to be easiest way how to get Source Tree and Git in Windows work with it out of the box.
- amelius 1y agoYes, that's how I use it too. However, this setup doesn't work with git-lfs (large file support). Or, at least I haven't been able to get it working. PS: Even though git-shell is very restricted you can still put shell commands in ~/git-shell-commands
- matrss 1y agoTo my knowledge git-lfs is only really designed to store your large files on a central server. I think it also uses its own out-of-band (from the perspective of git) protocol and connection to talk to that server. So it doesn't work with a standard ssh remote, and breaks git's distributed nature. For an actually distributed large file tracking system on top of git you could take a look at git-annex. It works with standard ssh remotes as long as git-annex is installed on the remote too (it provides its own git-annex-shell instead of git-shell), and has a bunch of additional awesome features.
- seba_dos1 1y agoJust make the repository on the server side bare and you won't have to worry about checked out branches or renaming ".git" directory.
- cl3misch 1y ago> This is a great way to [...] work on server-side files without laggy typing or manual copying This is the usecase mentioned in the article and it wouldn't work with a bare repo. But if the server your SSH'ing to is just a central point to sync code across machines, then you're right: multiple hoops mentioned in the article are solved by having the central repo bare.
- liveoneggs 1y agoyeah it seems odd that they don't just have remote> $HOME/repos/foo.git and then clone from there locally and remotely
- seba_dos1 1y agoFWIW a single user working on a remote versioned directory is indeed a reasonable use-case for receive.denyCurrentBranch=updateInstead, but IMO the article should have made it clear that it's not necessarily a good choice in general.
- kragen 1y agoSee https://news.ycombinator.com/item?id=45713074 https://news.ycombinator.com/item?id=45713074 for a worked example of how it works with a bare repo.
- ninkendo 1y agoI remember the first time I tried git, circa 2006, and the first 3 commands I tried were: git init git commit -am Initial\ commit git clone . ssh://server/path/to/repo And it didn’t work. You have to ssh to the remote server and “git init” on a path first. How uncivilized. Bitkeeper and a few other contemporaries would let you just push to a remote path that doesn’t exist yet and it’d create it. Maybe git added this since then, but at the time it seemed like a huge omission to me.
- seba_dos1 1y agoHah, you made me check whether clone's second argument can be a URL. But no, it's explicitly "<directory>", so it can't be used as a equivalent of "git push --mirror" :)
- deleted 1y ago[deleted]
- HumanOstrich 1y ago[flagged]
- ninkendo 1y agoLol I have no idea why you came away with “… and I never used git again!” from all that. I love git. It’s unironically one of my favorite pieces of software in the world. I’ve used it nearly every day for almost 20 years. Maybe take a break from HN for a bit, I mean that sincerely.
- 1oooqooq 1y agothis article is very bad advice. this way things are extremely brittle and there's a reason all those settings are disabled by default. you will lose data, save from very specific use cases the vastly superior way is 'git bare' which is a first class supported command without hacky settings.
- ezst 1y agoAs a git user "not by choice" (my preference going for mercurial every single day), I never understood why git needs this distinction between bare/non-bare (or commit vs staging for that matter). Seems like yet another leaky abstraction/bad design choice.
- skydhash 1y agoA repo is as database containing a tree of commits. Then you got the concept of branch, which points to a specific commit. Then there's the special pointer HEAD which is the latest commit for the current worktree. When you checkout (now switch) a branch, HEAD is now the same as the branch (they point to the same commit). When you do operation like commit, reset, reset,... both the head and the branch are updated. So if a remote node tries to update the local node via a push on its end, that would mess up the local worktree. So you create a bare repo instead which can't contain a local worktree. Note: A worktree is computed from the initial commit to the commit currently identified by HEAD by following the parent information on each commit. The staging area is like a stored snapshot of what you would like to commit. You can always create patch between HEAD and the worktree, edit it, and then save the patch as the commit, then apply the leftover to the worktree. The staging just make that easier. It's a WIP patch for the next commit.
- seba_dos1 1y ago> When you checkout (now switch) a branch, HEAD is now the same as the branch (they point to the same commit). Actually, HEAD now points to that branch, which in turn points to the commit. It's a different state than when HEAD points directly to the same commit (called "detached HEAD" in Git's terminology) where this issue doesn't happen as you're not on a branch at all. It's a subtle, but important distinction when trying to understand what happens under the hood there.
- skydhash 1y agoYou're right. I was trying to simplify.
- 1y ago
- bitbasher 1y agoI have been doing this for many years. If you want a public facing "read only" ui to public repositories you can use cgit (https://git.zx2c4.com/cgit/about/ https://git.zx2c4.com/cgit/about/) to expose them. That will enable others to git clone without using ssh. I keep my private repositories private and expose a few public ones using cgit.
- deleted 1y ago[deleted]
- LambdaComplex 1y agoHuh, I never realized that cgit was created by the same person that created wireguard.
- zyxin 1y agoI sent over a cgit web page for a take home assessment and the interviewer was horribly confused. I assume they have never seen anything apart from github before...
- bitbasher 1y agoI imagine the interviewer was one of those senior developers that still thinks git == github.
- max_ 1y agoI tried this and it is never as smooth as described. Why is GitHub popular? its not because people are "dumb" as others think. Its because GitHub "Just Works". You don't need obscure tribal knowledge like seba_dos1 suggests [0] or this comment https://news.ycombinator.com/item?id=45711294 https://news.ycombinator.com/item?id=45711294 The official Git documentation for example has its own documentation that I failed to get work. (it is vastly different from what OP is suggesting) The problem with software development is that not knowing such "tribal knowledge" is considered incompetence. People don't need to deal with obscure error messages which is why they choose GitHub & why Github won. Like the adge goes, "Technology is best when it is invisible" [0] https://news.ycombinator.com/item?id=45711236 https://news.ycombinator.com/item?id=45711236 [1] https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-...
- seba_dos1 1y agoAre basic git concepts like bare repos "obscure tribal knowledge" these days? What do you think ".git" directory is?
- max_ 1y agoHaving to make a repo bare to not have issues with branches is definitely obscure.
- deleted 1y ago[deleted]
- jdboyd 1y agoIt wasn't obscure before GitHub. Still, I like the online browser, and pr workflow.
- zenmac 1y agoYeah this is the best arguments for GitHub type of web git GUI. Not knowing bare repo seems just like a devs not reading docs. And I'm sorry in this day and age devs needs to keep up and just type git like curl http://...../install.sh type of thing. However would NEVER trust Github since the MS acquisition. codeberg and https://forgejo.org https://forgejo.org are perfectly sound FOSS alternative to GitHub and GigLabs nowdays.
- johnisgood 1y agoI am surprised how little software engineers (even those that use) know about git.
- general1465 1y agoThat's because git is hard to use and full of commands which are making no sense. Eventually people will learn to just clone, pull, push and occasionally merge and be done with it.
- skydhash 1y agoMost people would just use `app` `app (final)`, `app (final 2)`, etc... VCS exists for a reason and I strongly believe that the intersection of people that say git is hard and people that do not know why you want a VCS is nearly a perfect circle.
- xigoi 1y agoBeing a useful tool does not justify having an extremely inconsistent and unnecessarily confusing UI.
- jonhohle 1y agoPeople said the same thing about “advanced” operations with cvs and svn (and just called their admin for p4 or source safe). But I really don’t understand the sentiment. Managing code is one of the cornerstones of software engineering. It would be like refusing to learn how to use a screwdriver because someone really just wants to hammer things together. The great thing about $your-favorite-scm is that it transcends language or framework choices and is fungible for early any project, even outside of software. I’m surprised it isn’t part of more professional tools.
- general1465 1y ago> Managing code is one of the cornerstones of software engineering. It would be like refusing to learn how to use a screwdriver because someone really just wants to hammer things together. Ok, then make the commands make sense. For example 90%+ people has no idea what rebase does, yet it is a useful command. People does not want to learn with git outside of what works, because they can't experiment. The moment they will "hold it wrong" whole repo will break into pieces, unable to go forward or backwards. Hopefully they did not commit. Git feels like a hammer covered in razor blades. The moment you will try to hold it differently you will cut yourself and somebody else will need to stich you up.
- deleted 1y ago[deleted]
- timmg 1y agoThere was a brief period when Google Cloud had support for hosting git on a pay-per-use basis. (I think it was called Google Cloud Repositories.) It had a clunky but usable UI. I really preferred the idea of just paying for what I used -- rather than being on a "freemium" model with GitHub. But -- as many things with Google -- it was shutdown. Probably because most other people do prefer the freemium model. I wonder if this kind of thing will come back in style someday, or if we are stuck with freemium/pro "tiers" for everything.
- XorNot 1y agoMy git "server" is a folder of bare git repositories in home directory which I share with Syncthing. It'd be great if there was more specific support. But in practice? No problems so far.
- tasuki 1y agoPerhaps the only issue with this setup is that you lose some of the robustness of git: mess up one repo beoynd repair, and you've just messed up all the checkouts everywhere. I sync my repos manually (using GitHub as the always-on remote, but I'm not particularly attached to it). This gives me more resilience should I blow up the repo completely (hard to do, I know).
- eqvinox 1y agogit clone ssh://username@hostname/path/to/repo this is equivalent to: git clone username@hostname:path/to/repo and if your usernames match between local and remote: git clone hostname:path/to/repo (if the path has no leading /, it is relative to your home directory on the remote)
- deleted 1y ago[deleted]
- DrNefario 1y agoGit also respects your `~/.shh/config`, which lets you change settings per host. I've set up each of my GitHub accounts with a different "host" so it's easy to switch between them.
- mlrtime 1y agoI never thought about this.. I've had the following problem in the past. Host A, cannot reach official github.com. But Host B can and has a local copy of a repo cloned. So Host B can 'git clone ssh://' from Host A which is essentially equivalent, but just setting origin to Host B instead of github.com, sort of acting as a manual proxy? What if Host A is natted, so Host B can ssh to Host A but not the reverse, can Host G ssh clone to Host A to push changes? In the rare times I've needed this, I just 'rsync -av --delete' a repo from B->A.
- eqvinox 1y agoYou might want to read the documentation on "git remote". You can pull/fetch and push between repos quite arbitrarily, with plain ssh.
- blueflow 1y agoDocs: https://git-scm.com/docs/git-clone#_git_urls https://git-scm.com/docs/git-clone#_git_urls https://git-scm.com/docs/git-init https://git-scm.com/docs/git-init
- globular-toast 1y agoThe proper way to do this to make a "bare" clone on the server (a clone without a checked out branch). I was doing this in 2010 before I even signed up to GitHub.
- jonhohle 1y agoI feel like something was lost along the way. git init —-bare will give you a git repo without a working set (just the contents typically in the .git directory). This allows you to create things like `foo.git` instead of `foo/.git`. “origin” is also just the default name for the cloned remote. It could be called anything, and you can have as many remotes as you’d like. You can even namespace where you push back to the same remotes by changing fetch and push paths. At one company it was common to push back to `$user/$feature` to avoid polluting the root namespace with personal branches. It was also common to have `backup/$user` for pushing having a backup of an entire local repo. I often add a hostname namespace when I’m working from multiple hosts and then push between them directly to another instead of going back to a central server. For a small static site repo that has documents and server config, I have a remote like: [remote “my-server”] url = ssh+git://…/deploy/path.git fetch = +refs/heads/*:refs/remotes/my-server push = +refs/heads/*:refs/remotes/my-laptop So I can push from my computer directly to that server, but those branches won’t overwrite the server’s branches. It acts like a reverse `git pull`, which can be useful for firewalls and other situations where my laptop wouldn’t be routable.
- Sharlin 1y agoGit was always explicitly a decentralized, "peer to peer" version control system, as opposed to centralized ones like SVN, with nothing in the protocol itself that makes a distinction between a "server" and a "client". Using it in a centralized fashion is just a workflow that you choose to use (or, realistically, one that somebody else chose for you). Any clone of a repository can be a remote to any other clone, and you can easily have a "git server" (ie. just another directory) in your local filesystem, which is a perfectly reasonable workflow in some cases.
- webstrand 1y agoIt's a little more complex than that. Yes git can work in a peer-to-peer fashion, but the porcelain is definitely set up for a hub-and-spoke model, given how cloning a remote repo only gives you a partial copy of the remote history. There's other stuff too, like git submodules can't be configured to reference another branch on the local repository and then be cloned correctly, only another remote.
- tangotaylor 1y agoBeware of using this to publish static sites: you can accidentally expose your .git directory to the public internet. I got pwned this way before (by a pentester fortunately). I had to configure Apache to block the .git directory.
- jonhohle 1y agoInstead of excluding non-public directories, I like to make an explicit `public` directory (or `doc`, `doc-root`, whatever you want to call it). Then configure your server to point to that subdirectory and don’t worry about the repo. I usually throw `etc` and `log` directories at the top level as well and out my server config in etc, and have a gitignite rule to ignore everything in logs, but it’s there and ready for painless deployment. Since the web root is already a sub directory, more sensitive things can go into the same repo without worrying about exposing them.
- wizzwizz4 1y agoStoring volatile data (e.g. logs) in the git-managed directory is an excellent way to lose all your data. https://fediverse.blog/~/Prismo/on-prismo-data-loss https://fediverse.blog/~/Prismo/on-prismo-data-loss
- cesnja 1y agoYou can still get hit by a path traversal exploit. The safest option is to only have the public files on the server.
- jonhohle 1y agoA path traversal is different from putting private files in a public directory. For a simple static site there will always be certs, /etc, and other things outside of the document root that shouldn’t be served.
- CGamesPlay 1y agoBut what, exactly, was pwned? Did you have secrets in the git repo?
- binary132 1y agoThis is definitely nice but it doesn’t really support the full range of features of Git, because for example submodules cannot be local references. It’s really just easier to set up gitolite and use that in almost the same exact way but it’s much better.
- deleted 1y ago[deleted]
- mberning 1y agoI do something similar. I create a bare repo on my dropbox folder or nas mount. Then checkout from bare repo file path to some place where I will be doing all the work.
- prmph 1y agoThe more I use git, the more I discover more depth to it. So many features and concepts; it's easy to think you understand the basics, but you need to dig deep into it's origin and rationale to begin to grasp the way of thinking it is built around. And the API surface area is much larger than one would think, like an iceberg So I find it really weirdly low level in a way. Probably what is needed is is a higher-level CLI to use it in the most sensible, default way, because certainly the mental model most people use it with is inadequate.
- jrm4 1y agoCannot emphasize this whole notion enough; Very roughly, Github is to git what gmail is to email. It's mostly probably fine if that's the thing most of everybody wants to use and it works well; but also it's very unwise to forget that the point was NEVER to have a deeply centralized thing -- and that idea is BUILT into the very structure of all of it.
- morshu9001 1y agoIdk if git was designed to not be used in a centralized way. Like all other common CLIs, it was simply designed to work on your PC or server without caring who you are, and nothing stopped a corp from turning it into a product. Torvalds made git and Linux, then he put Linux on Github.
- ashton314 1y agoGit was explicitly designed to be decentralized.
- jrm4 1y agoIt's not a "CLI" and yes, "decentralized" was literally one of the points of it.
- morshu9001 1y ago"Distributed" was the point and the language their site uses*, not decentralized. It's only described as a convenience and reliability thing in contrast to the mess known as CVS. I haven't seen a note about avoiding one entity having too much power, even if that's a goal some users have in mind. Normally you have one master repo, or "blessed" as the site calls it. It's like, a Redis cluster is distributed but not decentralized. The ssh protocol is not decentralized. XMPP, Matrix, and Bitcoin are decentralized protocols, first two via federation. * https://git-scm.com/about/distributed https://git-scm.com/about/distributed
- semanticc 1y agoLinux is not developed in GitHub.
- ziofill 1y agoWhat is it with code on blog posts where fonts have uneven size and/or font types (e.g. italics mixed in with regular)? I see this from time to time and I wonder if it’s intentional.
- patal 1y agoHow would I sync access, if more than one people ssh-pushes onto the git repo? I assume syncing be necessary.
- tasuki 1y agoSame as always, with any other remote? (Use `git pull`? If the different people push to different branches, then there's no conflict and no problem. If you try to push different things into the same branch, the second person will get told their branch is out of date. They can either rebase or - if this is allowed by the repo config - force push over the previous changes...)
- kragen 1y agoYou probably want to use a bare repository (git init --bare) rather than `git config receive.denyCurrentBranch updateInstead`, which will cause your pushes to fail if you edit anything locally in the checkout. For http://canonical.org/~kragen/sw/dev3/ http://canonical.org/~kragen/sw/dev3/ I run a pull from the post-update hook of http://canonical.org/~kragen/sw/dev3.git http://canonical.org/~kragen/sw/dev3.git, http://canonical.org/~kragen/sw/dev3.git/hooks/post-update http://canonical.org/~kragen/sw/dev3.git/hooks/post-update, which is short enough that I'll just include it here: #!/bin/sh set -e echo -n 'updating... ' git update-server-info echo 'done. going to dev3' cd /home/kragen/public_html/sw/dev3 echo -n 'pulling... ' env -u GIT_DIR git pull echo -n 'updating... ' env -u GIT_DIR git update-server-info echo 'done.' You can of course also run a local site generator here as well, although for dev3 I took a lighter-weight approach — I just checked in the HEADER.html file that Apache FancyIndexing defaults to including above the file directory listing and tweaked some content-types in the .htaccess file. This could still fail to update the checkout if it has local changes, but only if they create a merge conflict, and it won't fail to update the bare repo, which is probably what your other checkouts are cloned from and therefore where they'll be pulling from.
- kragen 1y agoAlso bare repositories are a useful thing to put on USB pendrives.
- 3eb7988a1663 1y agoFor a USB drive, I would be more likely to use a bundle. Intended for offline distribution of a repository. Plus it is a single file, so you do not have to pay the transfer overhead of many small files.
- kragen 1y agoYou can repack your repo before you clone it onto the pendrive, and once it's there you can push and pull to it many times. Granted, pendrives are fast enough these days that copying an entire bundle every time is probably fine.
- tonymet 1y agoMy favorite git trick is using etckeeper & git subtree to manage multiple machines from a single repo . A single git repo can “fan out” to dozens of instances . It’s useful even for “managed” hosts with terraform because etckeeper snapshots config with every change, catching bugs in the terraform config. During the dev / compile / test flow, git makes a lightweight CI that reduces the exposure to your primary repo . Just run `watch -n 60 make` on the target and push using `git push` . The target can run builds without having any access to your primary (GitHub) repo.
- dlisboa 1y agoCare to share a little bit more about this? I've been thinking of using git with `--work-tree=/` to track system files, so I'm interested in these "unusual" setups with git. Not sure I got the "fan out" concept here.
- tonymet 1y ago`apt install etckeeper` will setup a repo in /etc/.git for you. It tracks any changes made via apt, and it runs nightly for other changes. On your primary repo, create dirs for each machine e.g. monorepo/ ├─ Machine1/ │ ├─ usr/share/www/ │ ├─ etc/ ├─ machine2/ │ ├─ etc/ Create remotes for each machine+repo e.g. `git remote add hosts/machine1/etc ssh://machine1/etc` then `git fetch hosts/machine1/etc` Then add the subtree with `git subtree add -P machine1/etc hosts/machine1/etc master` When you want to pull changes you can `git subtree pull` or `git subtree push …` If you end up making changes in your monorepo, use push. If you make changes directly on the machine (or via terraform), pull This way you can edit and manage dozens of machines using a single git repo, and git subtree push to deploy the changes. No deploy scripts.
- dlisboa 1y agoThanks, this sounds interesting. I wasn’t aware of etckeeper. So I take it you do periodic git pulls to update files and keep it all in check. The idea of a folder per machine is very good.
- joeyguerra 1y agoThere’s also git daemon.
- simonw 1y ago> It’s also backed up by default: If the server breaks, I’ve still got the copy on my laptop, and if my laptop breaks, I can download everything from the server. This is true, but I do also like having backups that are entirely decoupled from my own infrastructure. GitHub personal private accounts are free and I believe they store your data redundantly in more than one region. I imagine there's a way to setup a hook on your own server such that any pushes are then pushed to a GitHub copy without you having to do anything else yourself.
- nicce 1y ago> I imagine there's a way to setup a hook on your own server such that any pushes are then pushed to a GitHub copy without you having to do anything else yourself. For most people, that would defeat the purpose of self-hosting.
- simonw 1y agoIf your purpose for self-hosting is fear that GitHub will ignore their own promises in their terms of service and abuse their custody of your data then sure. https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#e-private-repositories https://docs.github.com/en/site-policy/github-terms/github-t... (There's also the "to comply with our legal obligations" bit, which is a concern if you're doing things that governments around the world may have issue with.) I expect there are people who like to self-host so that they're not dependent on GitHub up-time or having their accounts banned and losing access to their data. For them, having a secondary GitHub backup should still be useful.
- iwontberude 1y ago“By default, git won’t let you push to the branch that is currently checked out” TIL that people use non-bare git.
- mook 1y agoI use non-bare git because it's just transferring code between multiple machines for cross-platform locally run software; that is, it's just checkouts on mac, Windows, and Linux and commits being pushed amongst them. But then I also use worktrees and stuff, so maybe I'm weird.
- donatj 1y agoBack when I started at my current job... 15 years ago... We had no central git server. No PR workflow. We just git pull-ed from each others machines. It worked better than you would expect. We then went to using a central bare repo on a shared server, to hosted gitlab(? I think - it was Ruby and broke constantly) eventually landing on GitHub
- globular-toast 1y agoThis is classic git usage. A "pull request" was literally just asking someone to pull from your branch. GitHub co-opted the term for their own thing. The thing that people really don't seem to get these days is how your master branch is a different branch from someone else's master branch. So pulling from one master to another was a normal thing. When you clone you get a copy of all the branches. You can commit to your master branch all you want, it's yours to use however you want to.
- kragen 1y agoOn GitHub, too, a "pull request" is literally just asking someone to pull from your branch.
- hshdhdhehd 1y agoIsn't it asking someone to pull your branch (if forked) then merge it into to master
- kragen 1y agoGit pull is git fetch plus git merge.
- Sohcahtoa82 1y agoI've run into so many people that think "git pull" doesn't do anything unless you run "git fetch" first. In my 10+ year career, I'm not sure I've ever run "git fetch" manually. I've never had a time where I wanted to fetch upstream changes, but not merge (or rebase) them into my branch.
- cycomanic 1y agoI suspect many who always use git remotely don't know that you can easily work with local repositories as well using the file protocol, git clone file:///path/to/repository will create a clone of the repository at the path. I used that all the time when I had to move private repositories back and forth from work, without ssh access.
- lionkor 1y agoyou don't need to specify the protocol. For file protocol, just type a path. For ssh, type a ssh connection string like lion@myserver.test:path/to/file
- whirlwin 1y agoThis is how Heroku has been doing it for years since it started out 10+ years ago. $ git push heroku master So you'll have to make sure to push to e.g. GitHub as well for version control.
- gwd 1y agoGit post-update hooks to do deployment FTW. I looked into the whole push-to-github to kick off CI and deployment; but someone mentioned the idea of pushing over ssh to a repo on your server and having a post-update hook do the deployment, and that turned out to be much simpler.
- deleted 1y ago[deleted]
- quasarj 1y agoThis is, in fact, what git was made for
- hk1337 1y agoYou could just put a bare repo on a usb drive and pass it around but I wouldn’t recommend it.
- ctm92 1y agoyou don't even need ssh, you can also just store the remote on a local or remote file system
- Froztnova 1y agoHuh, y'know I shouldn't be surprised that this is possible given what I know about ssh and git. Yet I am.
- OhMeadhbh 1y agoYup. I do something similar: HTTPS://BI6.US/GI/B
- TZubiri 1y agoHmm. I typically have: - a prod server ( and a test server) with a git repo. - a local machine with the git repo. - a git server where code officially lives, nowadays just a github. If I were to simplify and run my own git server of the third kind, I would probably not run a server for the sole purpose of hosting code, it would most likely run on the prod/test server. So essentially I would be eliminating one node and simplifying. I don't know, maybe there's merits to having an official place for code to be in. Even if just semantics. I know you can also use branches to have a "master" branch with code and then have migrations just be merging from master into a prod branch, but then again, I could have just master branches, but if it's on the test server then it's the test branch. I don't know if spendint time reinventing git workflows is a very efficient use of brain juice though.
- m463 1y agoYou can do it with just directories too. mkdir -p repo/project cd repo/project git init --bare cd ../.. git clone repo/project cd project (do git stuff)
- mmaaz 1y agoSome time ago, I was on a team of researchers collaborating with a hospital to build some ML models for them. I joined the project somewhat late. There was a big fuss over the fact that the hospital servers were not connected to the internet, so the researchers couldn't use GitHub, so they had been stalled for months. I told them that before GitHub there was `git`, and it is already on the servers... I "set up" a git system for them.
- AoifeMurphy 1y agoSelf hosting Git isn’t just geek freedom, it’s a mindset of redundancy. I’ve had repos vanish due to platform bans that’s when it really hit me that “distributed” isn’t just a design, it’s a reminder of responsibility.
- BatteryMountain 1y agoIn interviews, I've literally asked senior devops engineers and senior software engineers if they have hosted their own git servers and how to initialise one and not a single one has mentioned git init --bare..... which is disconcerting. They can deploy appliances (like gitlab, gitea) and build pipelines just fine, but none of them realized how git actually works underneath and how simple it all is.
- catmanjan 1y agoWhy is that disconcerting? There's simply too much software to be familiar with obscure features like this
- Cthulhu_ 1y agoIn a sense it's anything but obscure, that is, it's one of the most basic of features of the tool and the first thing (well, git init anyway) anyone ever uses. But that's why people don't know about it, because they skip past the basics because in practice you never use it or need to know about it. This is the reality of software engineering and the like though - mostly you learn what you need to know, because learning everything is usually wasteful and never used, and there's a lot available. (I haven't been able to read documentation or a software book end to end in 20 years)
- JackMorgan 1y agoBecause too many bad interviews are all about ensuring that the candidate knows the exact same 1% of CS/SWE knowledge as the interviewer. Don't worry, karma dictates when the interviewer goes looking they'll get rejected for not knowing some similarly esoteric graph theory equation or the internal workings of a NIC card. Too much of our interviewing is reading the interviewer's mind or already knowing the answer to a trick question. The field is way too vast for anyone to even know a majority, and realistically it's extremely difficult to assess if someone is an expert in a different 1%. Sometimes I feel like we need a system for just paying folks to see if they can do the job. Or an actually trusted credentialing system where folks can show what they've earned with badges and such. A better interview question about this subject doesn't assume they have it memorized, but if they can find the answer in a short time with the internet or get paralyzed and give up. It's a very important skill to be able to recognize you are missing information and researching it on the Internet. For example, one of my most talented engineers didn't really know that much about CS/SWE. However, he had some very talented buddies on a big discord server who could help him figure out anything. I kid you not, this kid with no degree and no experience other than making a small hobby video game would regularly tackle the most challenging projects we had. He'd just ask his buddies when he got stuck and they'd point him to the right blog posts and books. It was like he had a real life TRRPG Contacts stat. He was that hungry and smart enough to listen to his buddies, and then actually clever enough to learn on the job to figure it out. He got done more in a week than the next three engineers of his cohort combined (and this was before LLMs). So maybe what we should test isn't data stored in the brain but ability to solve a problem given internet access.
- isolay 1y agoI wonder what's the missing link between this manual setup and something like gitea. Is gitea just automation of this?
- lukasnxyz 1y agoI do this for blog posts, but for server side work I just rsync my dir, much easier
- sam_lowry_ 1y agoIt's slightly more complicated to host your own git server on a generic linux box, because of file permissions. I wrote a HOWTO a few weeks ago: http://mikhailian.mova.org/node/305 http://mikhailian.mova.org/node/305
- cncjchsue7 1y agogit push prod Until you have more users than dollars that's all you need.
- brendyn 1y agoSo my friend and I were trying to learn some coding together. We had our laptops on the same wifi and I wanted us to use git without depending on GitHub, but I was completely stumped as to how to actually connect us together. I don't want us to setup SSH servers on each other's laptops, giving each other full access to our computers, and sending patches to each other across the living room seems overkill when we're just sitting around hacking away on our keyboards wanting to share what we've come up with every few minutes or so. I still have no idea how I would solve this. Maybe I'd just try coding with a syncthing directory shared between us, but then that's totally giving up on git
- ekzy 1y agoHave you tried git daemon? https://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon https://git-scm.com/book/en/v2/Git-on-the-Server-Git-Daemon
- OkayPhysicist 1y agoIf you put a git repository in a shared drive via git clone --bare (makes it not checkout a branch, and doesn't setup any origin type stuff), you can use that as a remote, pushing/pulling etc. Setting up a network available shared drive on one of the two computers shouldn't be too difficult, and by git's distributed nature it's not exactly the end of the world if access temporary. Another option would be to use the email-based workflow, but that's quite different from most people's expected git experience.
- xk3 1y agoI think if you just setup SSH a certain way you can then use git or sftp for access: Match User gituser ChrootDirectory /srv/git_chroot ForceCommand internal-sftp AllowTcpForwarding no X11Forwarding no PermitTTY no But tbh sending patches is fun and easy! After you force yourself to do it a few times you might even prefer it to push/pull
- pabs3 1y agoJust use netcat and send a git bundle across? Or if you are using Linux, there is a httpd (web server) in the busybox package: busybox httpd -f -p 0.0.0.0:10080 -h ~/public/
- JimmaDaRustla 1y agoGit is not a client/server architecture
- shravani_05_01 1y agoI have instagram id hack please
- banjwoorri 1y ago[dead]
- okoddcat 1y agoAnother alternative Open Source Git hosting tool https://github.com/gisiahq/gisia https://github.com/gisiahq/gisia