{"id":108,"date":"2023-09-08T23:30:17","date_gmt":"2023-09-08T22:30:17","guid":{"rendered":"https:\/\/codeblog.xyz\/?p=108"},"modified":"2023-10-23T20:07:26","modified_gmt":"2023-10-23T17:07:26","slug":"git-40-intermediate-level-questions","status":"publish","type":"post","link":"https:\/\/codeblog.xyz\/?p=108","title":{"rendered":"Git 40 intermediate-level questions"},"content":{"rendered":"\n<p>Below are 40 intermediate-level questions about Git, complete with answers and examples to deepen your understanding.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. What is Git rebase, and how does it differ from merge?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Both <code>git rebase<\/code> and <code>git merge<\/code> are used to integrate changes from one branch into another. <code>git rebase<\/code> moves a branch to a new base commit, while <code>git merge<\/code> creates a new commit that brings in changes from another branch.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Rebase: <code>git rebase main<\/code><\/li>\n\n\n\n<li>Merge: <code>git merge feature<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. What is a fast-forward merge?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A fast-forward merge happens when the feature branch is directly ahead of the base branch, allowing Git to simply move the HEAD pointer forward without creating a new commit.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git checkout main\ngit merge feature<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3. How do you squash commits?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git rebase -i HEAD~[n]<\/code> where <code>[n]<\/code> is the number of last commits you want to squash.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git rebase -i HEAD~3<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">4. What is a detached HEAD?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A detached HEAD occurs when you check out a commit that is not the tip of any branch, which can be dangerous for making changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. What are Git hooks?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Git hooks are scripts that run automatically before or after events like commit, push, and receive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. What is <code>git bisect<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git bisect<\/code> is a binary search tool that helps to find the commit that introduced a bug.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git bisect start\ngit bisect bad\ngit bisect good [good_commit]<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">7. How do you revert a specific file to a specific commit?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git checkout [commit_hash] -- [file_path]<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git checkout abc123 -- my-file.txt<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">8. What is a remote tracking branch?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: It&#8217;s a branch in your local Git repository that tracks a branch on a remote repository.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">9. What is <code>git annotate<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git annotate<\/code> is similar to <code>git blame<\/code>. It shows who made each change in a file and when, line by line.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git annotate my-file.txt<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">10. How do you rename a branch?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git branch -m [old_name] [new_name]<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git branch -m old-name new-name<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">11. How can you configure a global <code>.gitignore<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git config --global core.excludesFile '~\/.gitignore_global'<\/code> to set a global <code>.gitignore<\/code> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">12. What is <code>git stash pop<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git stash pop<\/code> applies stashed changes and removes them from the stash.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git stash pop<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">13. How do you remove a submodule?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: To remove a submodule, you need to delete the relevant section from <code>.gitmodules<\/code> and <code>.git\/config<\/code>, then run <code>git rm --cached [path_to_submodule]<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">14. What is <code>git clean<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git clean<\/code> is used to remove untracked files and directories.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git clean -fd<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">15. How do you configure aliases in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git config --global alias.[alias_name] '[git_command]'<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git config --global alias.st 'status'<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">16. How do you ignore changes in a tracked file temporarily?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git update-index --assume-unchanged [file]<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git update-index --assume-unchanged config.yml<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">17. What is a bare repository in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A bare repository is a Git repository without a working directory. It is suitable for sharing and collaborating.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">18. How do you archive a repository?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git archive<\/code> to create a tar or zip archive of a Git repository.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git archive --format=tar --output=\/path\/to\/archive.tar HEAD<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">19. How do you create and apply patches in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git format-patch<\/code> to create a patch and <code>git apply<\/code> to apply a patch.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git format-patch -1\ngit apply 0001-Commit-Message.patch<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">20. What are pre-receive, update, and post-receive hooks in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: These are server-side hooks. Pre-receive enforces rules before updates are done, update is invoked once for each branch, and post-receive runs after the update is accepted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">21. What is <code>git cherry<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git cherry<\/code> is used to find commits yet to be applied to the upstream.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git cherry -v main feature-branch<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">22. What does <code>git revert<\/code> do?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git revert<\/code> creates a new commit that undoes changes made in a specific commit, without rewriting history.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git revert [commit_hash]<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">23. What is a Git blob?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A blob (Binary Large Object) is a type of object that represents a file in Git. It stores the file data but doesn&#8217;t contain any metadata.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">24. What are Git sub-trees?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Git sub-trees allow you to embed one repository inside another as a sub-directory, without using submodules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">25. How do you set up a Git proxy?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: You can set up a Git proxy using the <code>http.proxy<\/code> or <code>https.proxy<\/code> configuration.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git config --global http.proxy http:\/\/proxy.example.com:8080<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">26. What is <code>git reflog<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git reflog<\/code> shows a log of where your <code>HEAD<\/code> and branch references have been, useful for recovering lost commits.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git reflog<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">27. How do you delete a local branch?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git branch -d [branch_name]<\/code> or <code>git branch -D [branch_name]<\/code> to forcefully delete.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git branch -d feature-branch<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">28. How do you delete a remote branch?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git push [remote_name] --delete [branch_name]<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git push origin --delete feature-branch<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">29. What is <code>git filter-branch<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git filter-branch<\/code> lets you rewrite Git revision history, such as changing email addresses, removing files, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">30. How do you configure different emails for different repositories?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: You can use <code>git config user.email [email]<\/code> within the repository directory to set a specific email for that repo.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git config user.email &quot;email@specific.repo&quot;<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">31. What is the Git staging area?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: The staging area is an intermediate area where commits can be formatted and reviewed before completing the commit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">32. What is <code>git gc<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git gc<\/code> (Garbage Collect) cleans up unnecessary files and optimizes the local repository.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git gc<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">33. What are symbolic references in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A symbolic reference is a file that contains a string that references another reference.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">34. How do you solve conflicts in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Conflicts can be solved manually by editing the conflicted files, then adding and committing them.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\"># Edit files to resolve conflict\ngit add .\ngit commit<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">35. What is a tracking connection in Git?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: A tracking connection links your local branch to the remote branch and helps you push, fetch, and pull changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">36. What is <code>git stash drop<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git stash drop<\/code> removes a single stashed state from the stash list.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git stash drop<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">37. How do you list only the files that have changed between two commits?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git diff --name-only [commit1] [commit2]<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git diff --name-only HEAD HEAD~1<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">38. What are Git notes?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Git notes are used to add metadata to Git objects like commits, without changing the objects themselves.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">39. How do you edit an incorrect commit message?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use <code>git commit --amend<\/code>.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git commit --amend -m &quot;New commit message&quot;<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">40. What is <code>git rev-parse<\/code>?<\/h3>\n\n\n\n<p><strong>Answer<\/strong>: <code>git rev-parse<\/code> parses Git references and returns the corresponding SHA-1 hash.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">git rev-parse HEAD<\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below are 40 intermediate-level questions about Git, complete with answers and examples to deepen your understanding. 1. What is Git rebase, and how does it differ from merge? Answer: Both git rebase and git merge are used to integrate changes from one branch into another. git rebase moves a branch to a new base commit, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":190,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[9,11,10],"class_list":["post-108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-git","tag-intermediate-level","tag-questions-and-answers"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=108"}],"version-history":[{"count":1,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":109,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/posts\/108\/revisions\/109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=\/wp\/v2\/media\/190"}],"wp:attachment":[{"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeblog.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}