{"id":22675491,"url":"https://github.com/wulfland/deepdive","last_synced_at":"2025-04-12T13:52:05.174Z","repository":{"id":41197380,"uuid":"459063488","full_name":"wulfland/DeepDive","owner":"wulfland","description":"A hands-on deep dive into working with git from the command line.","archived":false,"fork":false,"pushed_at":"2024-11-28T15:37:43.000Z","size":7122,"stargazers_count":8,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T01:39:46.571Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/wulfland.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":"2022-02-14T07:48:19.000Z","updated_at":"2024-11-28T15:37:47.000Z","dependencies_parsed_at":"2024-11-28T11:40:00.702Z","dependency_job_id":null,"html_url":"https://github.com/wulfland/DeepDive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wulfland%2FDeepDive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wulfland%2FDeepDive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wulfland%2FDeepDive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wulfland%2FDeepDive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wulfland","download_url":"https://codeload.github.com/wulfland/DeepDive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248576007,"owners_count":21127304,"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":["git"],"created_at":"2024-12-09T17:32:23.956Z","updated_at":"2025-04-12T13:52:05.153Z","avatar_url":"https://github.com/wulfland.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deep dive into git\n\nThis is the demo repo for a hands-on lab for working with git from the command line.\n\n## Before you start\n\n### Check yor git installation\n\nMake sure git is installed and the version is \u003e 2.23:\n\n```console\n$ git --version\n\u003e git version 2.35.1\n```\n\nIf not, [download](https://git-scm.com/downloads) and install git.\n\n### Check your git config\n\n1. Check your name and email address:\n\n```console\n$ git config --global user.name\n$ git config --global user.email\n```\n\nIf this does not return the desired values, set the config using these commands:\n\n```console\n$ git config --global user.name '\u003cyour_name\u003e'\n$ git config --global user.email '\u003cyour_email_address\u003e'\n```\n\n2. Set the default branch to `main`:\n\n```console\n$ git config --global init.defaultBranch main\n```\n\n3. Check your default editor\n\nCheck your default editor (i.e. by running `git config --global --edit`). If you like the editor, then you are good. If your stuck in vim (click \u003ckbd\u003eESC\u003c/kbd\u003e \u003ckbd\u003e:\u003c/kbd\u003e \u003ckbd\u003eq\u003c/kbd\u003e \u003ckbd\u003e!\u003c/kbd\u003e \u003ckbd\u003eEnter\u003c/kbd\u003e to exit), then configure the editor of your choice - for example CSCode:\n\n```console\n$ git config --global core.editor 'code --wait'\n```\n\n## Exercise 1: Understanding git\n\n### Set-up:\nCreate a local file/folder:\n\n```console\nmkdir UnderstandingGit\ncd UnderstandingGit\nmkdir folder;\nfor d in {1..6}; do echo  \"Line ${d}\" \u003e\u003e folder/file.txt; done;\n```\nPowershell:\n```console\nmkdir UnderstandingGit\ncd UnderstandingGit\nmkdir folder\nfor ($d=1; $d -le 6; $d++) { \"Line $d\" \u003e\u003e folder\\file.txt }\n\n```\n\n### Exercise\n\n1. Modify the file and verify its SHA value (`git hash-object`)\n2. Initialize the git repo (`git init`) and check the changes in your folder.\n3. Add file to index (`git add`).\n4. Commit file and check in your `.git` folder what a commit is (`git cat-file` and `git ls-tree`).\n5. Add another commit and verify how the two commits are connected.\n6. Create a sinple tag and an annotated tag (`git tag` and `git tag -a`).\n\n\u003cdetails\u003e\n  \u003csummary\u003eImportant commands for this exercise:\u003c/summary\u003e\n\n```\n$ git hash-object folder/file.txt\n$ git init\n$ git add\n$ git commit\n$ git ls-tree\n$ git cat-file [-p | -t]\n$ cat\n$ git tag [-a]\n```\n\u003c/details\u003e\n  \nA commit is a tree of blobs and trees:\n\n```mermaid\ngraph BT;\n    Tree==\u003eCommit;\n    Blob==\u003eTree;\n    Blob2==\u003eTree;\n    Tree2==\u003eTree;\n    Blob3==\u003eTree2;\n    Blob4==\u003eTree2;\n    Tree3==\u003eTree2;\n    Blob5==\u003eTree3;\n```\n  \nThe commits are connected to their parent commits (DAG):\n  \n```mermaid\ngraph RL;\n    96a85==\u003e49c01;\n    7e536==\u003e96a85;\n    1e542==\u003e7e536;\n    b7e6b==\u003e1e542;\n    main-.-\u003eb7e6b;\n    HEAD--\u003emain;\n    5a053==\u003e7e536;\n    55805==\u003e5a053;\n    branch-.-\u003e55805;\n    tag-.-\u003e55805;\n```\n\n## Exercise 2: Working with patches:\n\n1. Check how git generates diffs (`git diff`).\n2. Create patches for your two commits (`git format-patch`).\n3. Undo your changes (`git reset`).\n4. Apply the patches (`git apply` and `git am`).\n\n\n\u003cdetails\u003e\n  \u003csummary\u003eImportant commands for this exercise:\u003c/summary\u003e\n\n  ```console\n  $ git diff\n  $ git format-patch HEAD~2..HEAD\n  $ git reset --hard HEAD~2\n  $ git apply\n  $ git am\n  ```\n  \n\u003c/details\u003e\n  \n## Exercise 3: Merge conflicts\n\n### Set-up\n\n```console\necho \"Solving merge conflicts in git is easy\" \u003e Merge.txt\ngit add Merge.txt\ngit commit -m \"Base commit\"\ngit switch -c experiment\necho \"Solving merge conflicts is easy in git\" \u003e Merge.txt\ngit commit -am \"Modify Merge.txt in experiment\"\ngit switch main\necho \"Solving merge conflicts in git is very easy\" \u003e Merge.txt\ngit commit -am \"Modify Merge.txt in main\"\ngit switch experiment\n```\n\n### Exercise\n\nCreate a merge conflict with `git merge main` and resolve it.\n\u003cdetails\u003e\n  \u003csummary\u003eImportant commands for this exercise:\u003c/summary\u003e\n  \n  ```console\n  $ git config --global merge.conflictStyle diff3\n  $ git merge --abort\n  $ git diff\n  $ git log --merge –p \u003cfilename\u003e\n  $ git show :1:\u003cfilename\u003e (common ancestor)\n  $ git show :2:\u003cfilename\u003e (HEAD)\n  $ git show :3:\u003cfilename\u003e (MERGE_HEAD)\n\n  $ git add \u003cfilename\u003e\n  $ git merge --continue\n  ```\n  \n\u003c/details\u003e\n\n## Exercise 4: Working with your local history\n\n### Set-up:\n\nCreate a local history:\n\n```console\nmkdir WorkingWithYourHistory\ncd WorkingWithYourHistory\ngit init\nfor d in {1..6}; do touch \"file${d}.md\"; git add \"file${d}.md\"; git commit -m \"adding file ${d}\"; done\n```\n\nLook at you history. Create a git alias so that you don't have to type the long command all the time.\n\n```console\n$ git log --oneline --graph --decorate --all\n$ git config --global alias.lol 'log --oneline --graph --decorate --all'\n```\n\n### Exercise\n\n1. Add another file (`File7.md`) and ammend it to te last commit.\n2. Reset the last two commits and commit them together as a new commit (`git reset --soft`).\n3. Reset the last commit and create three commits out of it (`git reset --mixed`).\n4. Undo the last three commit (`git reset --hard`).\n5. Cherry pick the changes from the reflog.\n6. Do an interactive rebase. Reword commit 2 and edit commit 3. \n\n\u003cdetails\u003e\n  \u003csummary\u003eImportant commands for this exercise:\u003c/summary\u003e\n  \n  ```console\n  $ git commit --amend\n  $ git reset [--hard | --soft | --mixed]\n  $ git reflog\n  $ git cherry-pick\n  $ git rebase [-i]\n  ```\n  \n\u003c/details\u003e\n\n## Exercise 5: Branches, tags, finding bugs, and adding patches\n\n### Set-up:\n\n```console\n$ git clone https://github.com/wulfland/DeepDive.git DeepDive\n$ cd DeepDive\n```\n\n### Exercise\n\n1. Create a branch `fix-bug` to fix the bug (`git switch -c`)\n2. Switch to `main` and search in the history for the bug (`inde.html` instead of `index.html`) using `git bisect`.\n3. Modify Readme.md and commit to `main`.\n4. Switch to `fix-bug` and rename `inde.html` to `index.html`.\n5. Rebase the branch onto main. \n6. Create a branch `slow-down`.\n7. Modify line 9 of index.html and change the background URL to images/texture.jpg.\n8. Modify line 78 of index.html and change the timing for the game to speed it up or slow it down.\n9. Move `texture.jpg` to a new folder `images`.\n10. Create seperate commits for refactoring and logic changes (`git add -p`).\n11. Squash the changes into `main`\n\n\n\u003cdetails\u003e\n  \u003csummary\u003eImportant commands for this exercise:\u003c/summary\u003e\n  \n  ```console\n  $ git switch [-c]\n  $ git bisect start \n  $ git bisect good \u003cSHA\u003e\n  $ git bisect bad \u003cSHA\u003e\n  $ git bisect start \u003cGOOD\u003e \u003cBAD\u003e\n  $ git bisect run ls index.html\n  $ git add -p\n  $ git merge [--squash | --rebase]\n  ```\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwulfland%2Fdeepdive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwulfland%2Fdeepdive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwulfland%2Fdeepdive/lists"}