Tutorial: Introduction To Git

From Lorekeeper Wiki
Revision as of 00:43, 1 February 2021 by Wych(Witch) (talk | contribs) (Mostly done for now, saving to be safe)
Jump to navigation Jump to search

This guide is a work in progress!! Feel free to edit and fix any of my terminology or any other issues you may have. Or just add to this!


What is Git? How does it work?

Git is essentially a piece of software that saves all changes ever made to a file, but it can do so much more than just that. Let's break down the 7 common uses for Git.

Commits

Let's say you're a writer, and you want to save all of your drafts as you write and edit in case you want to roll back some of the changes. One way would be to manually save to separate files, such as draft1.doc, draft2.doc, ... draft242.doc..., but with git, it handles it for you whenever you Commit your changes!

Drafts Example.png






Each time you Commit your git directory a snapshot of the files that you have changed are saved, backing up the old changes at the same time! Instead of manually making copies of files or zipping up your entire folder, this is not only faster but more secure and flexible!

Switching current head.

What if you aren't satisfied with your current draft and want to roll back to an earlier version? Git has you covered? If you ever run into issues you can just jump back to an earlier Commit and continue from there!

Draft Example 2.png







Pulling and Pushing from/to remote Git

What if you want to back up your data to a remote server? Well that's also built into git! If you've ever heard of github or gitlab, they're sites made just for this (AND sharing/viewing code!)

Draft Example 3-2.png












Instead of something like dropbox which is automatic, git requires you to deliberately Push (upload) and Pull (download) whenever you want you update your files local or remote side.


Creating a new Branch and Checkout

What if you want to try to make some more drastic changes without having to keep track how many Commits you can create a copy of your current workspace, which is called Branching!

Draft Example 4.png










Each workspace in git is called a Branch, and creating a new branch is called Branching, and if you want to switch to a new branch, you have to Checkout that branch! The terms are weird, but it's not as complicated as it sounds!

Merging someone else's changes.

What if someone helped you with your writing and you want to combine it with yours? Instead of manually copy and pasting it, you can Pull their changes and Merge it into your file!

Draft Example 5.png








Even though I used writing a story for all of these examples, the primary way most people use it is for coding! (however plenty of people use it for writing too!)


Why is Git used for Lorekeeper?

Most if not all collaborative programming projects use a distributed version-control system like git to facilitate and keep track of changes to the codebase! Not only is it easy to learn and use, but it also keeps track of who pushed what changes! Without git, developing programs like Lorekeeper would be much, much harder than before.

Tips and Tricks

[WORK IN PROGRESS, FEEL FREE TO ADD SOME HERE]

Resources and Additional reading links

Tutorials

A great write up covering of the basics.

A great video covering the basics! Watch this if you're more of a audio learner!

A fantastic interactive tutorial. Go through this if you're still having trouble grasping the concepts!

Reference Guides

A really good and easy to read cheatsheet!

Something went wrong and you don't know how to fix it? This site has several helpful commands you can use to get back on track!