{"id":25767062,"url":"https://github.com/somnathkar000/git-handbook","last_synced_at":"2025-02-26T23:18:56.745Z","repository":{"id":216153542,"uuid":"738587960","full_name":"SomnathKar000/Git-Handbook","owner":"SomnathKar000","description":"This repo contains most of the useful commands of Git. ","archived":false,"fork":false,"pushed_at":"2024-01-09T15:34:27.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-09T18:51:30.415Z","etag":null,"topics":["git","version-control"],"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/SomnathKar000.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}},"created_at":"2024-01-03T15:17:31.000Z","updated_at":"2024-01-03T15:29:19.000Z","dependencies_parsed_at":"2024-01-08T18:45:08.881Z","dependency_job_id":"ef87a8b3-3045-445f-a685-1fbe734e637c","html_url":"https://github.com/SomnathKar000/Git-Handbook","commit_stats":null,"previous_names":["somnathkar000/git-handbook"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomnathKar000%2FGit-Handbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomnathKar000%2FGit-Handbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomnathKar000%2FGit-Handbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SomnathKar000%2FGit-Handbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SomnathKar000","download_url":"https://codeload.github.com/SomnathKar000/Git-Handbook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240948021,"owners_count":19883089,"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","version-control"],"created_at":"2025-02-26T23:18:56.181Z","updated_at":"2025-02-26T23:18:56.735Z","avatar_url":"https://github.com/SomnathKar000.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning Git Faster\n\nA curated list of essential Git commands and resources to help you learn Git faster.\n\n## Table of Contents\n\n1. [Core](#core)\n2. [Branching](#branching)\n3. [Merging](#merging)\n4. [Stashing](#stashing)\n5. [Remotes](#remotes)\n6. [Configuration](#configuration)\n7. [Plumbing](#plumbing)\n8. [Porcelain](#porcelain)\n9. [Alias](#alias)\n10. [Hook](#hook)\n11. [Experimental](#experimental)\n\n## Core\n\n- `git init`\n- `git clone`\n- `git add`\n- `git commit`\n- `git status`\n- `git diff`\n- `git checkout`\n- `git reset`\n- `git log`\n- `git show`\n- `git tag`\n- `git push`\n- `git pull`\n\n## Branching\n\n- `git branch`\n- `git checkout -b`\n- `git merge`\n- `git rebase`\n- `git branch --set-upstream-to`\n- `git branch --unset-upstream`\n- `git cherry-pick`\n\n## Merging\n\n- `git merge`\n- `git rebase`\n\n## Stashing\n\n- `git stash`\n- `git stash pop`\n- `git stash list`\n- `git stash apply`\n- `git stash drop`\n\n## Remotes\n\n- `git remote`\n- `git remote add`\n- `git remote remove`\n- `git fetch`\n- `git pull`\n- `git push`\n- `git clone --mirror`\n\n## Configuration\n\n- `git config`\n- `git global config`\n- `git reset config`\n\n## Plumbing\n\n- `git cat-file`\n- `git checkout-index`\n- `git commit-tree`\n- `git diff-tree`\n- `git for-each-ref`\n- `git hash-object`\n- `git ls-files`\n- `git ls-remote`\n- `git merge-tree`\n- `git read-tree`\n- `git rev-parse`\n- `git show-branch`\n- `git show-ref`\n- `git symbolic-ref`\n- `git tag --list`\n- `git update-ref`\n\n## Porcelain\n\n- `git blame`\n- `git bisect`\n- `git checkout`\n- `git commit`\n- `git diff`\n- `git fetch`\n- `git grep`\n- `git log`\n- `git merge`\n- `git push`\n- `git rebase`\n- `git reset`\n- `git show`\n- `git tag`\n\n## Alias\n\n- `git config --global alias.\u003calias\u003e \u003ccommand\u003e`\n\n## Hook\n\n- `git config --local core.hooksPath \u003cpath\u003e`\n\n## Experimental\n\n- `git annex`\n- `git am`\n- `git cherry-pick --upstream`\n- `git describe`\n- `git format-patch`\n- `git fsck`\n- `git gc`\n- `git help`\n- `git log --merges`\n- `git log --oneline`\n- `git log --pretty=`\n- `git log --short-commit`\n- `git log --stat`\n- `git log --topo-order`\n- `git merge-ours`\n- `git merge-recursive`\n- `git merge-subtree`\n- `git mergetool`\n- `git mktag`\n- `git mv`\n- `git patch-id`\n- `git p4`\n- `git prune`\n- `git pull --rebase`\n- `git push --mirror`\n- `git push --tags`\n- `git reflog`\n- `git replace`\n- `git reset --hard`\n- `git reset --mixed`\n- `git revert`\n- `git rm`\n- `git show-branch`\n- `git show-ref`\n- `git show-ref --heads`\n- `git show-ref --tags`\n- `git stash save`\n- `git subtree`\n- `git tag --delete`\n- `git tag --force`\n- `git tag --sign`\n- `git tag -f`\n- `git tag -l`\n- `git tag --verify`\n- `git unpack-file`\n- `git update-index`\n- `git verify-pack`\n- `git worktree`\n\n### Resources to Learn Git Faster\n\n1. [Git Official Documentation](https://git-scm.com/doc)\n2. [GitHub Learning Lab](https://rb.gy/ksc45f)\n3. [Codecademy Course](https://codecademy.com/learn/learn-git)\n4. [Pro Git: by Scott Chacon [Book]](https://git-scm.com/book/en/v2)\n5. [FreeCodeCampOrg- Beginner](https://rb.gy/ljxt5s)\n6. [FreeCodeCampOrg- Intermediate](https://rb.gy/1x6mc)\n7. [Programming with Mosh](https://rb.gy/vfkom)\n\n## Difference between `git pull` \u0026 `git fetch`\n\n`git pull` and `git fetch` are both Git commands used to retrieve changes from a remote repository, but they differ in how they integrate those changes into the local repository. Let's explore the differences with examples:\n\n### `git fetch`:\n\n- **Purpose:** Fetches changes from a remote repository to the local repository, but it does not automatically merge or rebase them into the working branch.\n- **Usage:**\n  ```bash\n  git fetch origin\n  ```\n- **Example Workflow:**\n\n  ```bash\n  # Fetch changes from the remote repository\n  git fetch origin\n\n  # View the changes fetched\n  git log origin/master\n\n  # Merge the fetched changes into the local branch (if desired)\n  git merge origin/master\n  ```\n\n### `git pull`:\n\n- **Purpose:** Fetches changes from a remote repository and automatically merges or rebases them into the working branch.\n- **Usage:**\n  ```bash\n  git pull origin master\n  ```\n- **Example Workflow:**\n  ```bash\n  # Fetch and merge changes from the remote repository into the current branch\n  git pull origin master\n  ```\n\n### Differences:\n\n1. **Automatic Integration:**\n\n   - `git fetch` fetches changes but leaves them in the remote-tracking branches (e.g., `origin/master`), and you need to explicitly merge or rebase.\n   - `git pull` fetches and integrates changes automatically, either by merging or rebasing.\n\n2. **Workflow:**\n\n   - With `git fetch`, you have more control over how and when you integrate changes.\n   - `git pull` is a shortcut that combines `git fetch` and either `git merge` or `git rebase`.\n\n3. **Commit History:**\n\n   - `git fetch` does not modify your local branches, preserving your commit history.\n   - `git pull`, especially with rebase, can rewrite commit history as it integrates changes.\n\n4. **Safety:**\n   - `git fetch` is safer in a collaborative environment, as it allows you to review changes before integration.\n   - `git pull` may automatically merge changes, which could lead to conflicts that need to be resolved.\n\n### Example Scenario:\n\nSuppose you're working on a branch named `feature-branch` and want to update it with changes from the remote `master` branch:\n\n- **Using `git fetch` and merge:**\n\n  ```bash\n  git fetch origin        # Fetch changes\n  git merge origin/master # Merge changes into your local branch\n  ```\n\n- **Using `git pull`:**\n  ```bash\n  git pull origin master  # Fetch and automatically merge changes\n  ```\n\nIn summary, use `git fetch` when you want to review changes before integrating them, and use `git pull` when you want a quick way to fetch and integrate changes automatically. The choice depends on your workflow and the level of control you want over the integration process.\n\n## Difference between `git merge` \u0026 `git reset`\n\n`git merge` and `git reset` are both Git commands that are used for different purposes in managing changes within a Git repository. Let's explore the differences between them with examples:\n\n### `git merge`:\n\n- **Purpose:** Combines changes from different branches, integrating them into the current branch.\n- **Usage:**\n  ```bash\n  git merge \u003cbranch-name\u003e\n  ```\n- **Example Workflow:**\n\n  ```bash\n  # Switch to the branch where you want to merge changes\n  git checkout target-branch\n\n  # Merge changes from the source branch\n  git merge source-branch\n  ```\n\n### `git reset`:\n\n- **Purpose:** Resets the current branch to a specified commit, either preserving or discarding changes.\n- **Usage:**\n  ```bash\n  git reset \u003ccommit\u003e\n  ```\n- **Example Workflow (Discarding Changes):**\n  ```bash\n  # Reset the branch to a specific commit, discarding changes\n  git reset --hard \u003ccommit\u003e\n  ```\n- **Example Workflow (Preserving Changes):**\n  ```bash\n  # Reset the branch to a specific commit, preserving changes as uncommitted\n  git reset --soft \u003ccommit\u003e\n  ```\n\n### Differences:\n\n1. **Operation:**\n\n   - `git merge` combines changes from different branches, creating a new commit that reflects the integration of changes.\n   - `git reset` moves the branch pointer to a specified commit, potentially discarding or preserving changes.\n\n2. **Commit History:**\n\n   - `git merge` introduces a new commit to represent the integration of changes, preserving the commit history of both branches.\n   - `git reset` modifies the commit history by moving the branch pointer, potentially discarding commits (with `--hard`) or preserving them as uncommitted changes (with `--soft`).\n\n3. **Branches:**\n   - `git merge` is typically used to merge changes between branches.\n   - `git reset` is often used for undoing commits or resetting the branch pointer.\n\n### Example Scenario:\n\nSuppose you have a feature branch (`feature-branch`) and you want to integrate its changes into the main branch (`main`). You have two options:\n\n- **Using `git merge`:**\n\n  ```bash\n  git checkout main         # Switch to the main branch\n  git merge feature-branch  # Merge changes from feature-branch into main\n  ```\n\n- **Using `git reset` to undo changes:**\n  ```bash\n  git checkout main         # Switch to the main branch\n  git reset --hard feature-branch  # Discard changes and move main pointer to feature-branch\n  ```\n  In this case, the `--hard` option discards all changes, including those made in the `feature-branch`. Be cautious when using `--hard` as it permanently discards changes.\n\nChoose between `git merge` and `git reset` based on your desired outcome and the nature of the changes you want to integrate or undo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomnathkar000%2Fgit-handbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomnathkar000%2Fgit-handbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomnathkar000%2Fgit-handbook/lists"}