Update
[less_retarded_wiki.git] / git.md
blobf96812b5be5ce269f162bd95ff981b54aa870dcf
1 # Git
3 Git (name without any actual meaning) is a [FOSS](foss.md) ([GPL](gpl.md)) [version control system](vcs.md) (system for maintaining and collaboratively developing [source code](source_code.md) of programs), currently the most mainstream-popular one (surveys saying over 90% developers use it over other systems). Git is basically a [command line](cli.md) program allowing to submit and track changes of text files (usually source code in some [programming language](programming_language.md)), offering the possibility to switch between versions, [branches](fork.md), detect and resolve conflicts in collaborative editing etc.
5 Git was created by [Linus Torvalds](linus_torvalds.md) in 2005 to host the development of [Linux](linux.md) and to improve on systems such as [svn](svn.md). Since then it has become extremely popular, mainly thanks to [GitHub](github.md), a website that offered hosting of git projects along with "social network" features for the developers; after this similar hosting sites such as [GitLab](gitlab.md) and [Codeberg](codeberg.md) appeared, skyrocketing the popularity of git even more.
7 It is generally considered quite a good software, many praise its distributed nature, ability to work offline etc., however diehard software idealists still criticize its mildly [bloated](bloat.md) nature and also its usage complexity -- it is non-trivial to learn to work with git and many errors are infamously being resolved in a "trial/error + google" style, so some still try to improve on it by creating new systems.
9 **Is git literally [hitler](hitler.md)?** Well, by [suckless](suckless.md) standards git IS bloated and yes, git IS complicated as fuck, however let's try to go deeper and ask the important questions, namely "does this matter so much?" and "should I use git or avoid it like the devil?". The answer is actually this: it doesn't matter too much that git is bloated and you don't have to avoid using it. Why? Well, git is basically just a way of hosting, spreading and mirroring your source onto many git-hosting servers (i.e. you can't avoid using git if you want to spread your code to e.g. Codeberg and GitLab) AND at the same time git doesn't create a [dependency](dependency.md) for your project, i.e. its shittiness doesn't "infect" your project -- if git dies or if you simply want to start using something else, you just copy-paste your source code elsewhere, you put it on [FTP](ftp.md) or anything else, no problem. It's similar to how e.g. [Anarch](anarch.md) uses [SDL](sdl.md) (which is bloated as hell) to run on specific platforms -- if it doesn't hard-depend on SDL and doesn't get tied to it, it's OK (and actually unavoidable) to make use of it. You also don't even have to get into the complicated stuff about git (like merging branches and resolving conflicts) when you're simply committing to a simple one-man project.
11 **Which git hosting to use?** All of them (except for [GitHub](github.md) which is a proprietary terrorist site)! Do not fall into the trap of [githopping](githopping.md), just make tons of accounts, one on each git hosting site, add multiple push remotes and just keep pushing to all of them -- EZ. Remember, git hosting sites are just free file storage servers, not social platforms or brands to identify with. Do NOT use their non-git "features" such as issue trackers, CI and shit. They want you to use them as "facebook for programmers" and become dependent on their exclusive "features", so that's exactly what you want to avoid, just abuse their platform for free file storage. Additional tip on searching for git hosting sites: look up the currently popular git website software and search for its live instances with some nice search engine, e.g. currently searching just `gitea` (or "powered by gitea", "powered by gogs", "powered by forgejo") on [wiby](wiby.md) returns a lot of free git hostings.
13 ## Alternatives
15 Here are some alternatives to git:
17 - **[nothing](nothing.md)**: If you don't have many people on the project, you can comfortably just use nothing, like in good [old](old.md) times. Share a directory with the source code and keep regular backups in separate directories, share the source online via [FTP](ftp.md) or something like that, let internet archive back you up.
18 - **[svn](svn.md)**: The "main", older alternative to git, used e.g. by [SourceForge](sourceforge.md), apparently suffers from some design issues.
19 - **[mailing list](mailing_list.md)**: Development happens over email, people just keep sending [patches](patch.md) that are reviewed and potentially merged by the maintainers to the main code base. This is how [Linux](linux.md) was developed before git.
20 - **[darcs](darcs.md)**: Alternative to git, written in [Haskell](haskell.md), advertising itself as simpler.
21 - **[lit](lit.md)** (previously known as *gut*): WIP [LRS](lrs.md)/[suckless](suckless.md) version control system.
22 - ...
24 ## How To Use Git For Solo/Small Projects (Cheatsheet)
26 TODO
28 - `git add files_you_changed; git commit -m "Update"; git push`
29 - `git pull`
30 - `git stash`
31 - `git rm file_to_remove`
32 - `git init`
33 - `git log`
34 - `git diff`
35 - `git apply diff_file`
36 - *weird error*: just look it up on stack overflow
38 ### Set Up Your Own Git Server
40 WIP
42 on server:
44 ```
45 mkdir myrepo
46 cd myrepo
47 git init --bare
48 ```
50 on client you can clone and push with ssh:
52 ```
53 git clone ssh://user@serveraddress:/path/to/myrepo
54 cd myrepo
55 ... # do some work
56 git commit -m "blablabla"
57 git push
58 ```
60 you can also make your repo clonnable via HTTP if you have HTTP server (e.g. [Apache](apache.md)) running, just have address `http://myserver/myrepo` point to the repo directory, then you can clone with:
62 ```
63 git clone http://myserver/myrepo
64 ```
66 IMPORTANT NOTE: for the HTTP clone to work you need to do `git update-server-info` on the server in the repo directory after every repo update! You can do this e.g. with a git hook or [cronjob](cronjob.md).
68 ## See Also
70 - [GitHub](github.md)
71 - [shithub](shithub.,d)