|
{ |
|
"data": [ |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
}, |
|
{ |
|
"question": "What is the intended use-case for git stash?", |
|
"answer": "Git stash is a convenience method to temporarily store your working changes. One key use-case is when you\u2019ve started working on a new patch but realize you forgot something in your last commit. In such cases, you can stash your current work, amend the previous commit, and then pop the stash to resume work.\n\nExample:\n```\n# Stash current changes\ngit stash save\n\n# Fix and amend the previous commit\ngit add -u\ngit commit --amend\n\n# Restore your stashed changes\ngit stash pop\n```\n\nWhile creating temporary branches is also a valid approach, stash is often faster for quick save-and-resume workflows.", |
|
"tags": [ |
|
"git", |
|
"git-stash" |
|
] |
|
}, |
|
{ |
|
"question": "What is the difference between 'git pull' and 'git fetch'?", |
|
"answer": "`git fetch` downloads changes from the remote repository into your local repository, but it does not modify your working directory. It simply updates the remote-tracking branches, allowing you to review the changes before merging.\n\n`git pull`, on the other hand, is essentially a combination of `git fetch` followed by `git merge`. It automatically integrates the remote changes into your current branch, which may lead to merge conflicts if your local changes conflict with remote ones.\n\n**Use `git fetch`** when you want to review changes before merging or rebasing.\n\n**Use `git pull`** for a one-step operation when you're confident and ready to merge remote changes directly.\n\nExample:\n```bash\ngit fetch origin\n# Review changes\ngit diff origin/main\n# Merge changes manually (optional)\ngit merge origin/main\n```\n\nOr simply:\n```bash\ngit pull origin main\n```", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-pull", |
|
"git-fetch" |
|
] |
|
}, |
|
{ |
|
"question": "How do I undo the most recent local commits in Git?", |
|
"answer": "If you have accidentally committed the wrong files locally and haven't pushed the changes yet, you can undo the most recent commit using:\n\n```bash\ngit reset HEAD~\n```\n\nThis command removes the most recent commit but leaves your working directory and index (staging area) untouched. You can then modify your files as needed and recommit.\n\nTo recommit with the same commit message:\n```bash\ngit commit -c ORIG_HEAD\n```\n\nIf you just want to edit the previous commit (including the message), you can use:\n```bash\ngit commit --amend\n```\n\nNote: If you had already pushed the commit, you'd need to use `git push --force-with-lease` to rewrite history on the remote, which is risky in shared repositories.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-commit", |
|
"undo" |
|
] |
|
}, |
|
{ |
|
"question": "How do I delete a Git branch locally and remotely?", |
|
"answer": "To delete a branch in Git, you need to consider whether you're deleting it locally or remotely:\n\n**Delete a local branch:**\n- If the branch is already merged:\n```bash\ngit branch -d <branch_name>\n```\n- If the branch is not merged and you still want to delete it:\n```bash\ngit branch -D <branch_name>\n```\n\n**Delete a remote branch:**\n```bash\ngit push <remote_name> --delete <branch_name>\n```\n\nIn most cases, `<remote_name>` is `origin`. This command removes the branch from the remote repository.\n\n**Note:** You cannot delete the branch you're currently on. Always switch to another branch (e.g., `main`) before deleting the target branch.", |
|
"tags": [ |
|
"git", |
|
"version-control", |
|
"git-branch", |
|
"git-push", |
|
"git-remote" |
|
] |
|
} |
|
] |
|
} |