{"id":22661414,"url":"https://github.com/vesalukkarila/version-control","last_synced_at":"2026-01-07T17:11:48.415Z","repository":{"id":267261734,"uuid":"881948803","full_name":"vesalukkarila/version-control","owner":"vesalukkarila","description":"Notes and exercises related to \"Everything you'll need to know about Git\"-course by The Primeagen.","archived":false,"fork":false,"pushed_at":"2024-11-04T15:08:01.000Z","size":778,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T22:47:46.256Z","etag":null,"topics":["git-course"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vesalukkarila.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-11-01T14:57:42.000Z","updated_at":"2024-11-15T16:26:48.000Z","dependencies_parsed_at":"2024-12-09T11:26:01.031Z","dependency_job_id":null,"html_url":"https://github.com/vesalukkarila/version-control","commit_stats":null,"previous_names":["vesalukkarila/version-control"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesalukkarila%2Fversion-control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesalukkarila%2Fversion-control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesalukkarila%2Fversion-control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vesalukkarila%2Fversion-control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vesalukkarila","download_url":"https://codeload.github.com/vesalukkarila/version-control/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246159059,"owners_count":20732913,"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-course"],"created_at":"2024-12-09T11:15:49.434Z","updated_at":"2026-01-07T17:11:48.377Z","avatar_url":"https://github.com/vesalukkarila.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# version-control\nCompleted FrontendMasters's wonderful course \"Everything you'll need to know about GIT\", held by The Primeagen. \nhttps://frontendmasters.com/courses/everything-git/  \nThis repository serves as a notebook for course-related notes and an enviroment for practicing skills with Git and Github.  \nIn the style of \"Learn in public\" this repository's branches also contain experimental attempts and unsuccessful trials. \nThe goal is also to keep track of things that are still unclear.   \nCertificate for the course completion can be found further down. \n\n## Concepts\n### 1. Merge (fast-forward) \nTwo branches, only the other one diverges. \nBest common ancestor is the tip of the  main branch, so new commits will be placed on top of that without a merge commit (fast forward). \n- On branch main: git merge foo\n```plaintext\nfoo             B - C  \n              /        =\u003e   A - B - C\nmain        A              \n```\n### 2. Merge (with merge commit, no conflict)\nTwo branches, both diverge on different files/lines.\nBest common ancestor exists, a merge commit will be created and it will have two parents, one from each branch.\n- On branch main: git merge foo\n```plaintext\nfoo             B - C           B - C \n              /         =\u003e    /       \\\nmain        A - D - E       A - D - E - (merge commit)\n```\n### 3. Rebase\nMoves foo to point to the latest commit on main\n- **Do not rebase on public branches, only on private**\n- On branch foo: git rebase main\n- if need to push to remote repo: git push --force\n\n```plaintext\nfoo            B - C                  B - C\n             /         =\u003e           /\nmain        A - D - E      A - D - E\n```\n\n## Memos\n### Basics\n**A commit**  \n\t- is a point in time representing the project in its entirety.   \n\t- Entiry project can be reconstructed from a single commit, representing project's state in commit's point in time.  \n\n**Staging area / index**  \n\t- you add files to index,i.e. collect files together you wish to include in a commit.  \n\n**sha**  \n- secure hash algorithm, built from the content of the object. Used as identifier for commit-objects, tree-objects and blob-objects.\n\n**Squash**  \n- take several commits and turn it into one commit.  \n\n**Best common ancestor / merge base**\n- the first in common commit\n\n**.git folder**  \nHolds all of git's history. Sha's can be found in .git/objects. First 2 letters as a directory, remaining 38 as a file.  \n``` git cat-file -p \u003csha\u003e```, to echo out the content of:  \n- commit object: holds metadata, commit message, tree-object, parent\n- tree-object: directory structure at the moment of the commit, holds blobs and trees\n- blob-object: a file, holds actual content of a file  \n\nBranches are stored in: .git/refs/heads/ a branch is also just a sha.\nLogs are stored in: .git/logs/HEAD\n\n**HEAD**  \nJust a pointer that points to what ever you are currently using.   \nThink of a playhead on a recorder.  \n\n**REFLOG**  \nShows where the HEAD has been.  \nExcercise:  \n- Create a branch and one commit in a new file\n- Delete the branch: ```git branch -D \u003cbranch\u003e```\n- Use git reflog to find the commit-object, \n- ```git cat-file -p \u003ccommit-object sha\u003e```\n- ```git cat-file -p \u003ctree-object sha\u003e```\n- ```git cat-file -p \u003cblob-object sha\u003e \u003e\u003e recoveredfile.md```\n- (easier way: cherry-pick)\n\n**Cherry Pick**  \nCherry pick the change the given commit introduces.  \nWorking tree must be clean before starting.  \n- ```git cherry-pick \u003csha\u003e```  \n\n**Stash**  \nWhen you have untracked changes and need to pull from remote\n- ```git stash -m \"msg\"```\n- ```git stash list```\n- ```git pull```\n- ```git stash pop```\n\n### Resolving conflicts\ngit pull --no-rebase (git config pull.rebase false): merge and resolve conflicts manually if any  \n- this will create a merge commit, which will have two parents\n\ngit pull --rebase (git config pull.rebase true): rebase and resolve conflicts manually if any  \n- rebases local commits on top of the remote changes, rewrites commits history\n\ngit pull --ff-only (git config pull.ff only): fails if divergents changes, no merge or rebase will occur  \n\n## Key takeaways\nCommit's (size\u0026quality\u0026messages) are very important. It is easier to fix things later (inevitable) when commits are done properly.  \n\n## Questions\nThe Primeagen about rebasing:  \n\"Likes to rebase when pulling in from remote.  \n- A long lived branch with a lot of merge commits is much more difficult to revert\n- Prefers to test his changes against the current state of master not against the current state he has fetched.\"  \n\n\n![image alt](https://github.com/vesalukkarila/version-control/blob/97284d209e04c130b65e94434aec72ae1facba7c/certificate.png)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvesalukkarila%2Fversion-control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvesalukkarila%2Fversion-control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvesalukkarila%2Fversion-control/lists"}