{"id":15798194,"url":"https://github.com/basokant/git-intro-workshop","last_synced_at":"2025-06-17T07:32:52.667Z","repository":{"id":179997650,"uuid":"599443244","full_name":"basokant/git-intro-workshop","owner":"basokant","description":"A repository for the Git(Hub) Intro workshop run for the members of Western Game Design Society.","archived":false,"fork":false,"pushed_at":"2023-02-10T01:57:19.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-09T01:37:27.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/basokant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-09T06:24:23.000Z","updated_at":"2023-02-10T00:28:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f2f024e-23e6-40c0-97b2-643ca6375d6f","html_url":"https://github.com/basokant/git-intro-workshop","commit_stats":{"total_commits":28,"total_committers":5,"mean_commits":5.6,"dds":0.3928571428571429,"last_synced_commit":"19009dd880eacf4da07fdca61d9bd5bf6564b6cc"},"previous_names":["basokant/git-intro-workshop"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/basokant/git-intro-workshop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basokant%2Fgit-intro-workshop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basokant%2Fgit-intro-workshop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basokant%2Fgit-intro-workshop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basokant%2Fgit-intro-workshop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basokant","download_url":"https://codeload.github.com/basokant/git-intro-workshop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basokant%2Fgit-intro-workshop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260313953,"owners_count":22990504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T00:23:58.401Z","updated_at":"2025-06-17T07:32:52.630Z","avatar_url":"https://github.com/basokant.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git(Hub) Intro Workshop\n\nA repository for the Git(Hub) Intro workshop run for the members of Western Game Design Society.\n\n## Resources\n\n- https://git-scm.com/downloads\n- https://rogerdudler.github.io/git-guide/\n- https://www.atlassian.com/git/tutorials/\n- https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet\n- https://github.com/skills/introduction-to-github\n\n## Outline\n\n### What is Git?\n\n- The **de facto** distributed version control system.\n\n- Git is like a **big album of _snapshots_** that helps you **keep track of changes** in your projects, and it's especially helpful when you're **working with others**.\n\n  - Imagine you're making a big Lego creation and you want to remember all the steps you took to build it.\n\n  - You could take a picture of your progress after each step, and then you would have a whole album of pictures showing how your Lego creation was built step by step.\n\n  - **Git does the same thing, but instead of pictures, it takes snapshots of your code.**\n\n  - This way, you can always go back to an earlier version if you need to make changes or fix a mistake.\n\n  - And if you're working on a project with friends, you can use Git to share your changes with each other and see who made what changes.\n\n- Developed in 2005 by Linus Torvalds (creator of Linux)\n\n### Install\n\nhttps://git-scm.com/downloads\n\n**Windows**: Use the installer, which comes with Git Bash (emulator for bash and git)\n\n** I recommend using [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) instead for various reasons.\n\n**Linux:** use your package manager of choice.\n\n**MacOS:** use homebrew/macports package manager, or the installer (recommend homebrew)\n\n### Pre-Requisites\n\n1. Have a text editor\n   1. VSCode (recommended)\n   2. NotePad++\n   3. (Neo)Vim\n   4. Emacs, etc.\n\n2. Know basic Bash commands\n   1. `cd`\n   2. `ls`\n   3. `rm`\n   4. `mkdir`\n   5. `touch`, etc.\n\n3. Have a GitHub account (create one here: https://github.com/join)\n\n### The Mental Model\n\n_Every committed change_ in Git is **stored as a snapshot** and referenced by a **unique hash**.\n\n- A **snapshot is not a diff**,\n- a **snapshot** is _an entire copy of the entire state of a system at a certain time._\n\n**All files go through three possible states.**\n\n1. **Untracked** ~ changes that are not recorded yet.\n2. **Staged** ~ ready to be snapshotted.\n3. **Committed** ~ snapshotted.\n\n![The Git Mental Model](https://bernhardwenzel.com/images/posts/2021/git-final-models.png)\n\nSource: Bernhard Wenzel\n\nA **commit** is _a copied collection of files in the repository representing their state at a certain time, along with a message, time, and unique hash._\n\nie. a \"safe\", recoverable, and uniquely identifiable version of the project.\n\n### Setting Up a Repository\n\nA **Git repository** is a special directory which allows you to save and access versions of your files.\n\n#### `git init`\n\n- `cd` into the project's directory, and run `git init` to initialize it as a repo.\n\n#### `git clone`\n\n- run `git clone \u003crepo url\u003e` to create a local clone of a remote repository.\n\nIn either case, you should see a `.git/` sub-directory in your project after initializing it as a repository.\n\n- [ ] Create a fork of this repository (here's how: https://docs.github.com/en/get-started/quickstart/fork-a-repo)\n- [ ] Clone that repository (https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)\n- [ ] Create a new branch for yourself using `git switch -c \u003clast 2 letters of last name\u003e\u003cfirst 2 letters of your first name\u003e`. Don't worry if this is confusing, we'll go through branching in more depth later!\n- [ ] Create a new directory, with a name of the form `\u003clast 2 letters of your last name\u003e\u003cfirst 2 letters of your first name\u003e`\n- [ ] Inside this directory, create a new file called `about-me.md`\n\n### Configuration\n\nIt's time to configure your Git name and email to be used by the system.\n\n```bash\ngit config --global user.name \u003cname\u003e\ngit config --global user.email \u003cemail\u003e\n```\n\n### The Git Workflow\n\nWere finally ready to make commits (or save changes) to our repository. This is the essence of the Git workflow, and what 95% of your Git usage will look like.\n\n1. _**Add**_ files that you want to commit to the **staging area**.\n   1. `git add \u003cfile name\u003e` adds a specific file to the staging area.\n   2. `git add \u003cdirectory name/path\u003e` adds all files in the directory to the staging area.\n\n2. _**Commit**_ everything in the staging area. `git commit -m \u003ccommit message\u003e`\n\nThe most common set of these 2 commands looks like this:\n\n```bash\ngit add .\ngit commit -m \"hopefully it works this time 🙏\"\n```\n\n![Git Workflow Diagram](https://wac-cdn.atlassian.com/dam/jcr%3A0f27e004-f2f5-4890-921d-65fa77ba2774/01.svg?cdnVersion%3D760)\n\nSource: Atlassian Git Tutorials\n\nWe can see the past commits with:\n\n```bash\ngit log\n```\n\nWe can check the current status that we're in (changes in the staging area and untracked changes).\n\n```bash\ngit status\n```\n\n** Writing good commit messages is DIFFICULT! I'd recommend following some of the rules found here: https://cbea.ms/git-commit/\n\n- [ ] Open the `about-me.md` file that you created in a text editor.\n- [ ] Answer the following question inside this file: What's a popular game everyone seems to love but you don't like? Why don't you like it?\n- [ ] Check the current status.\n- [ ] Commit this change.\n- [ ] Now answer the following question in the same file, below your answer to the previous one: What are your three favourite video games of all time?\n- [ ] Commit this change.\n\nYou can use `git checkout` to visit a past commit. (Move the HEAD pointer to another commit)\n\n```bash\ngit checkout \u003ccommit-sha\u003e\n```\n\n** Whenever git asks for a commit-sha, we can use `HEAD` to access the most recent commit (on the current branch), and `HEAD~1` to access 1 commit before the HEAD.\n\n** This can put you in a detached HEAD state, so be careful when making more commits.\n\n- [ ] Log the commit history.\n- [ ] Visit a previous commit with `git checkout`, and then go back to the most recent commit.\n- [ ] Now delete everything in the file!\n- [ ] Commit this change.\n\n### Undoing and Rewriting History\n\nWe can undo a commit in two ways:\n\n1. `git revert \u003ccommit-sha\u003e` creates a new commit with the inverse of the last commit.\n\n- use this for public shared repositories, not ideal for minimal Git history.\n\n2. `git reset --hard \u003ccommit-sha\u003e`\n\n- reset the commit history to that specified commit.\n\n- `--hard` nukes all untracked changes after reseting.\n\n- Without `--hard`, the changes will be untracked.\n\nWe can amend the most recent commit with\n\n```bash\ngit commit --amend\n```\n\n- opens an editor to edit the commit/commit message.\n\n![Git Checkout, Revert, and Reset](https://miro.medium.com/v2/resize%3Afit%3A1400/format%3Awebp/1%2AvsefSeRgwTGQqK-X2kpm6Q.png)\n\n- [ ] Revert the last commit (the delete).\n- [ ] Add your favourite food to the `about-me.md` file in a new line.\n- [ ] Hard reset to the last commit.\n- [ ] Hard reset to the commit before the delete.\n\n### Branches\n\n**Mental Model**\n\n- Every repository has at least one **branch**. Think of a branch as a specific timeline in the history.\n- A **branch** is a series of snapshots that represents a timeline of changes. Branches can start from any snapshot in the history.\n- Branches are key for collaboration with GitHub.\n\nWe've already been using a branch that we created!\n\n`git branch` ~ list all branches, and show current branch.\n\n- `-a` flag lists all, including remote/non-local branches.\n- `-d \u003cbranch-name\u003e` flag deletes a branch\n\n`git checkout \u003cbranch-name\u003e` ~ Check out a branch.\n\n- `-b` flag creates a new branch and checks it out.\n\n** Alternative is to use `git switch \u003cbranch-name\u003e` (and `-c` flag to create a new branch).\n\n- [ ] List all (including remote) branches.\n- [ ] Checkout the main branch. Notice how your directory and `about-me.md` file has disappeared.\n- [ ] Create a new branch called `temp` and switch to it.\n- [ ] Switch back to your branch.\n- [ ] Delete the `temp` branch.\n\nThere are two important branch operations in Git:\n\n**Rebase** ~ rebase the current branch onto a base branch/commit/tag.\n\n`git rebase \u003cbase\u003e`\n\n**Merge** ~ merge a branch into the current branch.\n\n`git merge \u003cbranch-name\u003e`\n\nWe're going to use a common technique called \"feature branching\", where we create a new branch for a feature and merge it in later.\n\n- [ ] List all (including remote) branches.\n- [ ] Create and switch to a new branch called `new-feature`\n- [ ] Inside your directory, create a new file called `new-file.txt`\n- [ ] Type \"hello world\" in the file.\n- [ ] Commit all changes.\n- [ ] Switch to your original branch and merge the `new-feature` branch into it.\n\n### Set-Up GitHub\n\n- [ ] Make an account (should be done)\n- [ ] Create a local SSH key.\n- [ ] Copy the SSH key to GitHub. (this is how authentication works)\n\n### Using GitHub\n\nGitHub is a hosting service for remote repository, a collaborative development platform, and weird social media platform all in one.\n\nOur local repository is a clone of the remote repository, where the remote is our source of truth. To push our changes, we simply must use:\n\n```bash\ngit push\n```\n\n`-u \u003cremote-name\u003e` specifies the remote name, which is required for the first push.\n\n**GitHub Flow**: how to collaborate on a public repository.\n\n1. Create a fork.\n2. Create a feature branch.\n3. [Submit a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request), and respond to any feedback with changes/comments.\n\nLet's submit a pull request!\n\n- [ ] Push your changes and new branch to your fork.\n- [ ] In GitHub, you should see an option to submit a pull request with this branch. Click the button, fill out the form, and submit!\n- [ ] Wait for me to merge it in.\n\n🎉 CONGRATS! Hopefully you know more Git than you did before! You'll never cry about losing your files again (unless you `rm -rf *` by accident 💀)\n\n___\n\n## Notes\n\n\u003cdetails\u003e\n\u003csummary\u003eNotes for Ben's 👀 only\u003c/summary\u003e\n\n- Focus on the **mental model** of Git/GitHub.\n- Only introduce git **fundamentals**, nothing fancy\n- Start from the **local workflow**, then move to the **remote workflow**\n- **USE VISUALS, DON’T JUST SAY “Run this command”.** Memorizing commands comes with time (not the focus of the workshop), **understanding the mental model** is vital in the beginning\n- Leave room for **questions**, **examples**, and **practice exercises**\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasokant%2Fgit-intro-workshop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasokant%2Fgit-intro-workshop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasokant%2Fgit-intro-workshop/lists"}