personal-website/posts/git-for-newbies/index.html

170 lines
60 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html><html lang=en dir=ltr class=scroll-smooth data-default-appearance=dark data-auto-appearance=true><head><meta charset=utf-8><meta http-equiv=content-language content="en"><meta name=viewport content="width=device-width,initial-scale=1"><meta name=theme-color content="rgb(255,255,255)"><meta http-equiv=x-ua-compatible content="ie=edge"><title>Git For Newbies &#183; baalajimaestro</title><meta name=title content="Git For Newbies &#183; baalajimaestro"><meta name=description content="Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.
Commands that a user should type on his/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don&rsquo;t have to type $ on your terminal."><link rel=canonical href=https://baalajimaestro.me/posts/git-for-newbies/><link type=text/css rel=stylesheet href=/css/main.bundle.min.a6debbb9c2752cfaaf987cbf5014fd1df44fb95b3494591ae67b7f8b99579a03.css integrity="sha256-pt67ucJ1LPqvmHy/UBT9HfRPuVs0lFka5nt/i5lXmgM="><script type=text/javascript src=/js/appearance.min.022d0ebc3b46a335eb1c7ef79b7f2de143d7cd5156d433638592ef1ce5f8554e.js integrity="sha256-Ai0OvDtGozXrHH73m38t4UPXzVFW1DNjhZLvHOX4VU4="></script>
<link rel=apple-touch-icon sizes=180x180 href=/apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=/favicon-16x16.png><link rel=manifest href=/site.webmanifest><meta property="og:title" content="Git For Newbies"><meta property="og:description" content="Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.
Commands that a user should type on his/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don&rsquo;t have to type $ on your terminal."><meta property="og:type" content="article"><meta property="og:url" content="https://baalajimaestro.me/posts/git-for-newbies/"><meta property="article:section" content="posts"><meta property="article:published_time" content="2019-06-18T12:29:41+08:00"><meta property="article:modified_time" content="2019-06-18T12:29:41+08:00"><meta name=twitter:card content="summary"><meta name=twitter:title content="Git For Newbies"><meta name=twitter:description content="Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.
Commands that a user should type on his/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don&rsquo;t have to type $ on your terminal."><script type=application/ld+json>[{"@context":"https://schema.org","@type":"Article","articleSection":"Blog","name":"Git For Newbies","headline":"Git For Newbies","abstract":"Before we start make sure git --version command successfully returns. If the output is something like command not found then please make sure Git is properly installed on your machine. My machine output is shown below. Output on your machine might be different.\nCommands that a user should type on his\/her terminal are prefixed with the shell prompt symbol $. The output of command follows the command. Also, you don\u0026rsquo;t have to type $ on your terminal.","inLanguage":"en","url":"https:\/\/baalajimaestro.me\/posts\/git-for-newbies\/","author":{"@type":"Person","name":"baalajimaestro"},"copyrightYear":"2019","dateCreated":"2019-06-18T12:29:41\u002b08:00","datePublished":"2019-06-18T12:29:41\u002b08:00","dateModified":"2019-06-18T12:29:41\u002b08:00","mainEntityOfPage":"true","wordCount":"2908"}]</script><meta name=author content="baalajimaestro"><script>var _paq=window._paq=window._paq||[];_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),function(){e="https://counter.baalajimaestro.me/",_paq.push(["setTrackerUrl",e+"86eff12f2496"]),_paq.push(["setSiteId","1"]);var e,n=document,t=n.createElement("script"),s=n.getElementsByTagName("script")[0];t.async=!0,t.src=e+"dd168412e25a.js",s.parentNode.insertBefore(t,s)}()</script><script>window.location.hostname!=="baalajimaestro.me"&&window.location.hostname!=="www.baalajimaestro.me"&&window.location.replace("https://baalajimaestro.me"+window.location.pathname)</script></head><body class="flex flex-col h-screen px-6 m-auto text-lg leading-7 max-w-7xl bg-neutral text-neutral-900 dark:bg-neutral-800 dark:text-neutral sm:px-14 md:px-24 lg:px-32"><div id=the-top class="absolute flex self-center"><a class="px-3 py-1 text-sm -translate-y-8 rounded-b-lg bg-primary-200 focus:translate-y-0 dark:bg-neutral-600" href=#main-content><span class="font-bold pe-2 text-primary-600 dark:text-primary-400">&darr;</span>Skip to main content</a></div><header class="py-6 font-semibold text-neutral-900 dark:text-neutral print:hidden sm:py-10"><nav class="flex items-start justify-between sm:items-center"><div class="flex flex-row items-center"><a class="decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2" rel=me href=/>baalajimaestro</a></div><ul class="flex list-none flex-col ltr:text-right rtl:text-left sm:flex-row"><li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0.5"><a href=/about/ title="About Me"><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">About</span></a></li><li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0.5"><a href=/posts/ title=Blog><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">Blog</span></a></li><li class="group mb-1 sm:mb-0 sm:me-7 sm:last:me-0.5"><a href=/contact/ title="Contact Me"><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">Contact</span></a></li></ul></nav></header><div class="relative flex flex-col grow"><main id=main-content class=grow><article><header class=max-w-prose><ol class="text-sm text-neutral-500 dark:text-neutral-400 print:hidden"><li class="inline hidden"><a class="hover:underline decoration-neutral-300 dark:underline-neutral-600" href=/>baalajimaestro</a><span class="px-1 text-primary-500">/</span></li><li class=inline><a class="hover:underline decoration-neutral-300 dark:underline-neutral-600" href=/posts/>Blog</a><span class="px-1 text-primary-500">/</span></li><li class="inline hidden"><a class="hover:underline decoration-neutral-300 dark:underline-neutral-600" href=/posts/git-for-newbies/>Git For Newbies</a><span class="px-1 text-primary-500">/</span></li></ol><h1 class="mt-0 text-4xl font-extrabold text-neutral-900 dark:text-neutral">Git For Newbies</h1><div class="mt-8 mb-12 text-base text-neutral-500 dark:text-neutral-400 print:hidden"><div class="flex flex-row flex-wrap items-center"><time datetime="2019-06-18 12:29:41 +0800 +0800">18 June 2019</time><span class="px-2 text-primary-500">&#183;</span><span title="Reading time">14 mins</span></div></div></header><section class="flex flex-col max-w-full mt-0 prose dark:prose-invert lg:flex-row"><div class="min-w-0 min-h-0 max-w-prose grow"><p>Before we start make sure <code>git --version</code> command successfully returns. If the output is something like <strong>command not found</strong> then please make sure Git is properly installed on your machine. My machine output is shown below. <strong>Output on your machine might be different.</strong></p><blockquote><p><strong>Commands that a user should type on his/her terminal are prefixed with the shell prompt symbol <code>$</code>. The output of command follows the command. Also, you don&rsquo;t have to type <code>$</code> on your terminal.</strong></p></blockquote><p>Please be nice to Mr.Git. Introduce yourself to him. Else git will blame you for not introducing yourself <code>please tell me who you are!</code></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git config --global user.name <span class=s2>&#34;Your name&#34;</span>
</span></span><span class=line><span class=cl>$ git config --global user.email <span class=s2>&#34;Your email&#34;</span>
</span></span></code></pre></div><p>The command shown above populates a file named <code>.gitconfig</code> in your user home directory with configuration information.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ cat ~/.gitconfig
</span></span></code></pre></div><pre tabindex=0><code>[user]
name = baalajimaestro
email = baalajimaestro@computer4u.com
</code></pre><h2 id=table-of-contents class="relative group">Table of Contents <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#table-of-contents aria-label=Anchor>#</a></span></h2><ul><li>Why version control system?</li><li>What the heck is Git?</li><li>Git basics<ul><li>git init</li><li>git status</li><li>git add</li><li>git commit</li><li>git rm</li><li>git log</li><li>.gitignore files</li></ul></li><li>Working with branches<ul><li>git branch</li><li>git checkout</li><li>git merge</li></ul></li><li>Working with remote repositories<ul><li>git remote</li><li>git pull</li><li>git push</li><li>git clone</li></ul></li><li>Github basics<ul><li>Why and What Pull Requests?</li></ul></li><li>Advanced topics<ul><li>git rebase</li><li>git cherry-pick</li><li>git alias</li></ul></li><li>Useful Git commands</li></ul><h2 id=vcs-version-control-system class="relative group">VCS: Version Control System <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#vcs-version-control-system aria-label=Anchor>#</a></span></h2><p>A version control system is a kind of database for storing your software project source code. It lets you save a snapshot of your complete project at any time you want. When you later take a look at an older snapshot (let&rsquo;s start calling it &ldquo;version&rdquo;).</p><p>You can use version control system to store:</p><ol><li>Software source code</li><li>Text files</li><li>Writing books</li><li>Sharing datasets</li></ol><h2 id=why-version-control-system class="relative group">Why version control system? <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#why-version-control-system aria-label=Anchor>#</a></span></h2><p>You should use version control because it offers the below:</p><ol><li>Collaboration among a team of Coders</li><li>Versioning the code. Could create multiple branches to setup binary releases</li><li>Restoring to previous versions</li><li>Tracking the history (who to blame!)</li><li>Backup. Old style backup methodologies like email storage, local file system or FTP backup are cumbersome.</li></ol><h2 id=what-the-heck-is-git class="relative group">What the heck is Git? <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#what-the-heck-is-git aria-label=Anchor>#</a></span></h2><p>Git is a distributed version control system. It was developed by Linus Torvalds in 2005 for linux developers and is being maintained by a large community across the world.</p><p>Every Git working directory is a full-fledged repository with complete history and full version-tracking capabilities, independent of network access or a central server.</p><img src=https://upload.wikimedia.org/wikipedia/commons/e/e0/Git-logo.svg width=150 height=150><p>Distributed or Decentralized VCS allows many software developers to work on a project without requiring them to share a common network.</p><h2 id=git-basics class="relative group">Git basics <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-basics aria-label=Anchor>#</a></span></h2><p>Let&rsquo;s start by creating an empty directory <code>git-basic</code>. Navigate to a convenient location on your local file system and create a new directory.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ mkdir git-basic <span class=o>&amp;&amp;</span> <span class=nb>cd</span> git-basic
</span></span></code></pre></div><h3 id=git-init class="relative group">git init <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-init aria-label=Anchor>#</a></span></h3><p>To make any repository a Git managed repository, you can type the following command. These commands should be typed from inside the <code>git-basic</code> directory.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git init
</span></span></code></pre></div><pre tabindex=0><code>Initialized empty Git repository in ~/git-basic/.git/
</code></pre><p>This will create a directory named <code>.git</code> inside the <code>git-basic</code> directory.</p><p><code>.git</code> is a directory where Git stores all the data. <strong>Don&rsquo;t mess with the <code>.git</code> directory.</strong></p><p>If you want to override user for this repository, then you can add user section by either editing <code>.git/config</code> file or using the <code>git config --local</code> command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git config --local user.name <span class=s2>&#34;Shekhar 123&#34;</span>
</span></span></code></pre></div><p>If you view the contents of the <code>.git/config</code> file now, then you will see your change.</p><h3 id=git-status class="relative group">git status <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-status aria-label=Anchor>#</a></span></h3><p>Time and again we will need to know status of our Git repository. By status what we mean is the current state of the repository. E.g., what needs to be added to the index, what needs to be committed, if there is any change that we have to commit, etc., This is the command that you will use the most.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git status
</span></span></code></pre></div><pre tabindex=0><code>On branch master
Initial commit
nothing to commit (create/copy files and use &#34;git add&#34; to track)
</code></pre><h3 id=git-add class="relative group">git add <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-add aria-label=Anchor>#</a></span></h3><p>Let&rsquo;s create a new file <code>README.md</code> and add a dummy message.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;# Git Basics&#34;</span> &gt;&gt; README.md
</span></span></code></pre></div><blockquote><p><strong>It is a good practice to create a file named README.md in your repository root that tells the purpose of the repository.</strong></p></blockquote><p>Now, check the status of the Git repository.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git status
</span></span></code></pre></div><pre tabindex=0><code>On branch master
Initial commit
Untracked files:
(use &#34;git add &lt;file&gt;...&#34; to include in what will be committed)
README.md
nothing added to commit but untracked files present (use &#34;git add&#34; to track)
</code></pre><p><strong>git add</strong> stages the changes so they are picked up by the next commit. In Git, you can&rsquo;t commit something until its tracked.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git add README.md
</span></span></code></pre></div><p>Now, check the status of your Git repository.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git status
</span></span></code></pre></div><pre tabindex=0><code>On branch master
Initial commit
Changes to be committed:
(use &#34;git rm --cached &lt;file&gt;...&#34; to unstage)
new file: README.md
</code></pre><blockquote><p><strong>If you have multiple files then you can use <code>git add &lt;file1> &lt;file2> .. &lt;filen></code> or <code>git add --all</code> or <code>git add -A</code> to stage them in one command.</strong></p></blockquote><h3 id=git-commit class="relative group">git commit <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-commit aria-label=Anchor>#</a></span></h3><p>Once you have a smallest working change, you should commit it to your version control system. Smallest working change could be a test case, a small piece of functional code, a line or paragraph in your text file, etc. <strong>You should commit often and daily.</strong> Also, every commit should strive to do exactly one change.</p><p>After staging your changes, next step is to commit them into your local Git repository. To do that, we will use commit command as shown below.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git commit -m <span class=s2>&#34;first commit&#34;</span>
</span></span></code></pre></div><pre tabindex=0><code>[master (root-commit) 3d34eb3] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
</code></pre><p>Staging and committing are two different steps in Git. You can&rsquo;t commit a change until it has been staged. If you are working with a tracked file, then you can do both of these steps in a single command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;This is my Git.&#34;</span> &gt;&gt; README.md
</span></span></code></pre></div><p>Check the status of your repository. This time it will say it is a <strong>modified</strong> change.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git status
</span></span></code></pre></div><pre tabindex=0><code>On branch master
Changes not staged for commit:
(use &#34;git add &lt;file&gt;...&#34; to update what will be committed)
(use &#34;git checkout -- &lt;file&gt;...&#34; to discard changes in working directory)
modified: README.md
no changes added to commit (use &#34;git add&#34; and/or &#34;git commit -a&#34;)
</code></pre><p>To stage and commit a change in a tracked file, you can use following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;second commit&#34;</span>
</span></span></code></pre></div><h3 id=git-rm class="relative group">git rm <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-rm aria-label=Anchor>#</a></span></h3><p>Let&rsquo;s suppose we added a bad file to the Git index that we want to remove.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;my stupid file&#34;</span> &gt;&gt; stupid.txt
</span></span><span class=line><span class=cl>$ git add stupid.txt
</span></span></code></pre></div><p>To remove such a file from the Git index, we can use Git <code>rm</code> command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git rm -f stupid.txt
</span></span></code></pre></div><p>To remove directories,</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git rm -rf crap
</span></span></code></pre></div><h3 id=git-log class="relative group">git log <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-log aria-label=Anchor>#</a></span></h3><p>To view history of your commit logs, use the following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log
</span></span></code></pre></div><p>If you want to see a commit in one line, then use <code>--oneline</code> option.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline
</span></span></code></pre></div><p>There are many more options. You can refer to help <code>git help log</code> for more details.</p><h3 id=gitignore-files class="relative group">.gitignore files <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#gitignore-files aria-label=Anchor>#</a></span></h3><p>Every Git repository should have another configuration file <code>.gitignore</code> present in the root i.e. directly inside the <code>git-basic</code> directory. This file is used to specify files and file patterns that you want git to ignore .</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;*.log&#34;</span> &gt;&gt; .gitignore
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;target/&#34;</span> &gt;&gt; .gitignore
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;dummy.txt&#34;</span> &gt;&gt; .gitignore
</span></span></code></pre></div><ol><li>The first pattern says any file with extension <code>log</code> will ignored.</li><li>The second pattern says directory with name <code>target</code> will be ignored.</li><li>The third pattern means file with name <code>dummy.txt</code> will be ignored.</li></ol><p>Now add and commit the <code>.gitignore</code> to your Git repository.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git add .gitignore
</span></span><span class=line><span class=cl>$ git commit -m <span class=s2>&#34;Adding .gitignore file&#34;</span>
</span></span></code></pre></div><h2 id=working-with-branches class="relative group">Working with branches <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#working-with-branches aria-label=Anchor>#</a></span></h2><p>A branch represents an independent line of development. You use branch for following:</p><ol><li>Develop a new feature. Once you are done with the feature, it can be merged into your main branch.</li><li>Fix a bug.</li><li>Your experiment playground.</li></ol><p>By default, every git repository has one branch called <strong>master</strong>. When you create a new branch, you get a new development workspace. Any change that you make to the new working directory has no impact on your previous working directory.</p><h3 id=git-branch class="relative group">git branch <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-branch aria-label=Anchor>#</a></span></h3><p><strong>git branch</strong> command lets you work with Git branches.</p><p>To view all the branches, you execute following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git branch
</span></span><span class=line><span class=cl>* master
</span></span></code></pre></div><blockquote><p><strong>branch marked with a * is the current branch.</strong></p></blockquote><p>Let&rsquo;s suppose we have to implement some new functionality. To work on new functionality, we create a new branch called <code>feature1</code>.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git branch feature1
</span></span></code></pre></div><p>You can view branch list again.</p><pre tabindex=0><code>$ git branch
feature1
* master
</code></pre><p>One thing that is important to understand here is Git branches are just pointers to commits. When you create a branch, all Git needs to do is create a new pointer; it doesnt change the repository in any other way.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline --decorate
</span></span></code></pre></div><h3 id=git-checkout class="relative group">git checkout <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-checkout aria-label=Anchor>#</a></span></h3><p>To switch to a branch, you use checkout command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout feature1
</span></span></code></pre></div><p>The <code>git checkout</code> command lets you navigate between the branches created by git branch.</p><p>To create a new branch and checkout it in one command</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout -b feature1
</span></span></code></pre></div><p>Let&rsquo;s add our new feature now.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will read a Git tutorial today to make sure I understand Git thoroughly.&#34;</span> &gt;&gt; README.md
</span></span></code></pre></div><p>Commit it to the <code>feature1</code> branch.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;fifth commit. Read tutorial&#34;</span>
</span></span></code></pre></div><h3 id=git-merge-ff class="relative group">git merge (ff) <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-merge-ff aria-label=Anchor>#</a></span></h3><p>Once we are done with our feature, we can merge it back to master. First, we&rsquo;ll switch to <code>master</code> branch.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout master
</span></span></code></pre></div><p><strong>git merge</strong> command allows you to merge an independent development line created by <code>git branch</code> into a single branch.</p><blockquote><p>git merge will merge into the current branch.</p></blockquote><p>To merge <code>feature1</code> branch into <code>master</code> branch, execute the following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git merge feature1
</span></span></code></pre></div><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline --decorate
</span></span></code></pre></div><blockquote><p>the default merge algorithm is ff i.e fast forward. When the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. This is the default behavior.</p></blockquote><p>A <strong>fast-forward</strong> merge can occur when there is a linear path from the current branch tip to the target branch.</p><p>Now that we are done with <code>feature1</code> branch, let&rsquo;s delete it.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git branch -d feature1
</span></span></code></pre></div><h3 id=git-merge---no-ff class="relative group">git merge (&ndash;no-ff) <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-merge---no-ff aria-label=Anchor>#</a></span></h3><p>Create another new branch <code>feature2</code> and add a new commit.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout -b feature2
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;sixth commit. Watch video.&#34;</span>
</span></span></code></pre></div><p>Now checkout master again.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout master
</span></span></code></pre></div><p>The <code>--no-ff</code> algorithm always generate a merge commit (even if it was a fast-forward merge)</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git merge --no-ff feature2
</span></span></code></pre></div><p>View logs of master</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline --decorate
</span></span></code></pre></div><p>The interesting bit is that it created a merge commit. Git uses Three-way merge algorithm.</p><ol><li>the <code>MERGE_HEAD</code> commit i.e. the modification that we want to merge</li><li>the <code>HEAD</code> commit i.e. the branch in which the <code>MERGE_HEAD</code> will be merged i.e. the branch on which the git merge command is called</li><li>the <code>ORIG_HEAD</code> commit i.e. the best common ancestor of <code>MERGE_HEAD</code> and <code>HEAD</code> that will serve as the reference.</li></ol><p>Delete the feature branch <code>feature2</code></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git branch -d feature2
</span></span></code></pre></div><h3 id=git-merge-commits-in-both-master-and-branch class="relative group">git merge (commits in both master and branch) <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-merge-commits-in-both-master-and-branch aria-label=Anchor>#</a></span></h3><p>Create another new branch <code>feature2</code> and add a new commit.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout -b feature3
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will try Git using tutorial https://try.github.io/&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;seventh commit. Try Git.&#34;</span>
</span></span></code></pre></div><p>Checkout master branch and edit an existing line.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout master
</span></span></code></pre></div><p>Change <strong>I will read a Git tutorial today to make sure I understand Git thoroughly.</strong> to <strong>I will read a Git tutorial <a href=https://www.atlassian.com/git/tutorials/ target=_blank rel="noreferrer noopener">https://www.atlassian.com/git/tutorials/</a>.</strong></p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ cat README.md
</span></span></code></pre></div><pre tabindex=0><code># Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
</code></pre><p>Now, commit the change to master branch.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;fixed Git tutorial bullet point&#34;</span>
</span></span></code></pre></div><p>Now merge the <code>feature3</code> branch. This will create a merge commit.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git merge feature3
</span></span></code></pre></div><p>View the log graph.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline --graph
</span></span></code></pre></div><h3 id=git-merge-conflict class="relative group">git merge (conflict) <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-merge-conflict aria-label=Anchor>#</a></span></h3><p>In this section, we will look at scenario where there is a merge conflict. Merge conflict happens when you&rsquo;re trying to merge a branch that has changed the same part of the same file as master. Let&rsquo;s create a new branch <code>feature4</code>, make a change, and commit.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout -b feature4
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will create a Github account today.&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;eighth commit. Signup for Github.&#34;</span>
</span></span></code></pre></div><p>Now, checkout master, make a change, and then commit it.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout master
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will create my first repository today.&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;eighth commit. Create repository on Github.&#34;</span>
</span></span></code></pre></div><p>If you try to merge the <code>feature4</code> branch, you will get merge conflict as shown below.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git merge feature4
</span></span></code></pre></div><pre tabindex=0><code>Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
</code></pre><p>To merge the conflict, open the file in your favorite editor. I like <a href=https://github.com/atom/atom target=_blank rel="noreferrer noopener">Atom</a>.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ cat README.md
</span></span></code></pre></div><pre tabindex=0><code># Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
I will try Git using tutorial https://try.github.io/
&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
I will create my first repository today.
=======
I will create a Github account today.
&gt;&gt;&gt;&gt;&gt;&gt;&gt; feature4
</code></pre><p>The merged output is shown below.</p><pre tabindex=0><code># Git Playground
This is my Git playground.
I will learn Git today during the XKE.
I will read a Git tutorial https://www.atlassian.com/git/tutorials/.
I will watch a Git video by Linus Torvalds https://www.youtube.com/watch?v=4XpnKHJAok8
I will try Git using tutorial https://try.github.io/
I will create a Github account today.
I will create my first repository today.
</code></pre><p>To make the merge resolved, execute <code>git add</code> command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git add README.md
</span></span></code></pre></div><p>Commit it</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;Resolved merged conflict with feature4 branch&#34;</span>
</span></span></code></pre></div><h2 id=working-with-remote-repositories class="relative group">Working with remote repositories <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#working-with-remote-repositories aria-label=Anchor>#</a></span></h2><p>In Git, every developer has their own local copy of the repository. It has all the repository history and branches. A developer works on their local copy and when done with the work, the changes can be pushed to a remote repository. A local repository can point to 0 or more remote repositories. A remote repository could be on Github or any other cloud VCS provider or even it could be on your own machine.</p><h3 id=git-remote class="relative group">git remote <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-remote aria-label=Anchor>#</a></span></h3><p>The <strong>git remote</strong> command lets you create, view, and delete connections to other repositories.</p><p>To view all the remotes, execute the following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git remote
</span></span></code></pre></div><p>As we have not added any remote yet, this command will not print any output.</p><p>To add a new remote, execute the following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git remote add <span class=nb>local</span> ../git-basic-remote.git
</span></span></code></pre></div><blockquote><p><strong>Please use correct path to your remote repository.</strong></p></blockquote><p>To push our repository changes to this remote repository we can run the following command. This command will be executed from inside the <code>git-basic</code> directory.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git push <span class=nb>local</span> master
</span></span></code></pre></div><pre tabindex=0><code>Counting objects: 37, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (37/37), 3.41 KiB | 0 bytes/s, done.
Total 37 (delta 11), reused 0 (delta 0)
To ../git-basic-remote.git
* [new branch] master -&gt; master
</code></pre><p>Now, you can create multiple local copies of the remote repository using <code>clone</code> command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git clone git-basic-remote.git git-basics
</span></span></code></pre></div><pre tabindex=0><code>Cloning into &#39;git-basics&#39;...
done.
</code></pre><p>Change directory and view the contents.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>cd</span> git-basic-1
</span></span></code></pre></div><p>You can see history of the repository using <code>git log --oneline --decorate</code> command.</p><p>Let&rsquo;s make a change in <code>git-basics</code> repository.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will read Git in Practice book&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;ninth commit. Read book.&#34;</span>
</span></span><span class=line><span class=cl>$ git push <span class=nb>local</span> master
</span></span></code></pre></div><p>To get changes in our first repository i.e. <code>git-basic</code>, you will use <code>pull</code> command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git pull <span class=nb>local</span> master
</span></span></code></pre></div><h2 id=github-basics class="relative group">Github basics <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#github-basics aria-label=Anchor>#</a></span></h2><p>Github is a collaborative code management platform for open source and private projects. It has social features just like any other social website like Facebook, Twitter, etc.</p><p>You use Github to store your code on a remote Git repository.</p><p>You can <a href=https://github.com/join target=_blank rel="noreferrer noopener">sign up</a> for Github.</p><h3 id=create-a-repository class="relative group">Create a repository <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#create-a-repository aria-label=Anchor>#</a></span></h3><p>Create a <a href=https://github.com/new target=_blank rel="noreferrer noopener">new repository</a>.</p><p>Give it name <code>git-bas</code> and choose defaults.</p><h3 id=add-remote class="relative group">add remote <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#add-remote aria-label=Anchor>#</a></span></h3><p>From inside your <code>git-basic</code>, execute the following command.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git remote add origin https://github.com/baalajimaestro/git-basic.git
</span></span></code></pre></div><h3 id=git-push class="relative group">git push <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-push aria-label=Anchor>#</a></span></h3><p>Push the changes to Github.</p><h3 id=create-pull-request class="relative group">Create pull request <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#create-pull-request aria-label=Anchor>#</a></span></h3><ol><li>Clone your repo on your local machine.</li><li>Commit and push the changes to your fork</li><li>Create a pull request</li></ol><h3 id=git-rebase class="relative group">git rebase <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-rebase aria-label=Anchor>#</a></span></h3><p>Rebasing is the process of moving a branch to a new base commit. It is used to keep Git history linear so you will not have merge commits.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout -b feature5
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will prefer rebase over merge to avoid merge commit.&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;tenth commit. Prefer rebase over merge&#34;</span>
</span></span></code></pre></div><p>Work on master branch.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git checkout master
</span></span><span class=line><span class=cl>$ <span class=nb>echo</span> <span class=s2>&#34;I will prefer merge over rebase as it is easy to understand.&#34;</span> &gt;&gt; README.md
</span></span><span class=line><span class=cl>$ git commit -am <span class=s2>&#34;Merge over Rebase&#34;</span>
</span></span></code></pre></div><p>Rebase command</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git rebase feature5 master
</span></span></code></pre></div><p>Fix merge conflicts.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git add README.md
</span></span><span class=line><span class=cl>$ git rebase --continue
</span></span></code></pre></div><p>Now view the logs using</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git log --oneline --decorate --graph
</span></span></code></pre></div><p>Delete the branch</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git branch -d feature5
</span></span></code></pre></div><h3 id=git-cherry-pick class="relative group">git cherry-pick <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-cherry-pick aria-label=Anchor>#</a></span></h3><p>Applying a commit from one branch to another</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git cherry-pick &lt;commit-hash&gt;
</span></span></code></pre></div><h3 id=git-alias class="relative group">git alias <span class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100"><a class="group-hover:text-primary-300 dark:group-hover:text-neutral-700" style=text-decoration-line:none!important href=#git-alias aria-label=Anchor>#</a></span></h3><p>Allows you write your own commands or shortcuts. Like we have been using <code>git log --oneline --decorate --graph</code>.</p><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl>$ git config --global alias.mylog <span class=s2>&#34;log --oneline --decorate --graph&#34;</span>
</span></span></code></pre></div></div></section><footer class="pt-8 max-w-prose print:hidden"><div class=flex><img class="!mb-0 !mt-0 me-4 h-24 w-24 rounded-full" width=96 height=96 alt=baalajimaestro src=/logo_hud38acf383e8b0ec59a144c7188a6b106_63924_192x192_fill_q75_h2_box_center_2.webp loading=lazy><div class=place-self-center><div class="text-[0.6rem] uppercase leading-3 text-neutral-500 dark:text-neutral-400">Author</div><div class="font-semibold leading-6 text-neutral-800 dark:text-neutral-300">baalajimaestro</div><div class="text-2xl sm:text-lg"></div></div></div><section class="flex flex-row flex-wrap justify-center pt-4 text-xl"><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://www.facebook.com/sharer/sharer.php?u=https://baalajimaestro.me/posts/git-for-newbies/&amp;quote=Git%20For%20Newbies" title="Share on Facebook" aria-label="Share on Facebook" target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentcolor" d="M504 256C504 119 393 8 256 8S8 119 8 256c0 123.78 90.69 226.38 209.25 245V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14.0 55.52 4.84 55.52 4.84v61h-31.28c-30.8.0-40.41 19.12-40.41 38.73V256h68.78l-11 71.69h-57.78V501C413.31 482.38 504 379.78 504 256z"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://twitter.com/intent/tweet/?url=https://baalajimaestro.me/posts/git-for-newbies/&amp;text=Git%20For%20Newbies" title="Tweet on Twitter" aria-label="Tweet on Twitter" target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentcolor" d="M459.37 151.716c.325 4.548.325 9.097.325 13.645.0 138.72-105.583 298.558-298.558 298.558-59.452.0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055.0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421.0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391.0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04.0-57.828 46.782-104.934 104.934-104.934 30.213.0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://reddit.com/submit/?url=https://baalajimaestro.me/posts/git-for-newbies/&amp;resubmit=true&amp;title=Git%20For%20Newbies" title="Submit to Reddit" aria-label="Submit to Reddit" target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentcolor" d="M201.5 305.5c-13.8.0-24.9-11.1-24.9-24.6.0-13.8 11.1-24.9 24.9-24.9 13.6.0 24.6 11.1 24.6 24.9.0 13.6-11.1 24.6-24.6 24.6zM504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-132.3-41.2c-9.4.0-17.7 3.9-23.8 10-22.4-15.5-52.6-25.5-86.1-26.6l17.4-78.3 55.4 12.5c0 13.6 11.1 24.6 24.6 24.6 13.8.0 24.9-11.3 24.9-24.9s-11.1-24.9-24.9-24.9c-9.7.0-18 5.8-22.1 13.8l-61.2-13.6c-3-.8-6.1 1.4-6.9 4.4l-19.1 86.4c-33.2 1.4-63.1 11.3-85.5 26.8-6.1-6.4-14.7-10.2-24.1-10.2-34.9.0-46.3 46.9-14.4 62.8-1.1 5-1.7 10.2-1.7 15.5.0 52.6 59.2 95.2 132 95.2 73.1.0 132.3-42.6 132.3-95.2.0-5.3-.6-10.8-1.9-15.8 31.3-16 19.8-62.5-14.9-62.5zM302.8 331c-18.2 18.2-76.1 17.9-93.6.0-2.2-2.2-6.1-2.2-8.3.0-2.5 2.5-2.5 6.4.0 8.6 22.8 22.8 87.3 22.8 110.2.0 2.5-2.2 2.5-6.1.0-8.6-2.2-2.2-6.1-2.2-8.3.0zm7.7-75c-13.6.0-24.6 11.1-24.6 24.9.0 13.6 11.1 24.6 24.6 24.6 13.8.0 24.9-11.1 24.9-24.6.0-13.8-11-24.9-24.9-24.9z"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://www.linkedin.com/shareArticle?mini=true&amp;url=https://baalajimaestro.me/posts/git-for-newbies/&amp;title=Git%20For%20Newbies" title="Share on LinkedIn" aria-label="Share on LinkedIn" target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentcolor" d="M416 32H31.9C14.3 32 0 46.5.0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6.0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3.0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2.0 38.5 17.3 38.5 38.5.0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6.0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2.0 79.7 44.3 79.7 101.9V416z"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="mailto:?body=https://baalajimaestro.me/posts/git-for-newbies/&amp;subject=Git%20For%20Newbies" title="Send via email" aria-label="Send via email" target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentcolor" d="M207.8 20.73c-93.45 18.32-168.7 93.66-187 187.1-27.64 140.9 68.65 266.2 199.1 285.1 19.01 2.888 36.17-12.26 36.17-31.49l1e-4-.6631c0-15.74-11.44-28.88-26.84-31.24-84.35-12.98-149.2-86.13-149.2-174.2.0-102.9 88.61-185.5 193.4-175.4 91.54 8.869 158.6 91.25 158.6 183.2v16.16c0 22.09-17.94 40.05-40 40.05s-40.01-17.96-40.01-40.05v-120.1c0-8.847-7.161-16.02-16.01-16.02l-31.98.0036c-7.299.0-13.2 4.992-15.12 11.68-24.85-12.15-54.24-16.38-86.06-5.106-38.75 13.73-68.12 48.91-73.72 89.64-9.483 69.01 43.81 128 110.9 128 26.44.0 50.43-9.544 69.59-24.88 24 31.3 65.23 48.69 109.4 37.49C465.2 369.3 496 324.1 495.1 277.2V256.3c0-149.2-133.9-265.632-287.3-235.57zM239.1 304.3c-26.47.0-48-21.56-48-48.05s21.53-48.05 48-48.05 48 21.56 48 48.05-20.6 48.05-48 48.05z"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://telegram.me/share/url?url=https://baalajimaestro.me/posts/git-for-newbies/&amp;text=Git%20For%20Newbies" title aria-label target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg></span></a><a class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800" href="https://news.ycombinator.com/submitlink?u=https://baalajimaestro.me/posts/git-for-newbies/&amp;t=Git%20For%20Newbies" title aria-label target=_blank rel="noopener noreferrer"><span class="relative inline-block align-text-bottom px-1 icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentcolor" stroke="none"><path d="M0 24V0h24v24H0zM6.951 5.896l4.112 7.708v5.064h1.583v-4.972l4.148-7.799h-1.749l-2.457 4.875c-.372.745-.688 1.434-.688 1.434s-.297-.708-.651-1.434L8.831 5.896h-1.88z"/></svg></span></a></section><div class=pt-8><hr class="border-dotted border-neutral-300 dark:border-neutral-600"><div class="flex justify-between pt-3"><span></span><span><a class="group flex text-right" href=/posts/extract-vendor/><span class="flex flex-col"><span class="mt-[0.1rem] leading-6 group-hover:underline group-hover:decoration-primary-500">Vendor Blob Extraction</span>
<span class="mt-[0.1rem] text-xs text-neutral-500 dark:text-neutral-400"><time datetime="2019-10-10 21:24:00 +0530 +0530">10 October 2019</time></span></span>
<span class="ms-2 text-neutral-700 transition-transform group-hover:-translate-x-[2px] group-hover:text-primary-600 dark:text-neutral dark:group-hover:text-primary-400"><span class="ltr:inline rtl:hidden">&rarr;</span><span class="ltr:hidden rtl:inline">&larr;</span></span></a></span></div></div></footer></article><div class="pointer-events-none absolute bottom-0 end-0 top-[100vh] w-12"><a href=#the-top class="pointer-events-auto sticky top-[calc(100vh-5.5rem)] flex h-12 w-12 items-center justify-center rounded-full bg-neutral/50 text-xl text-neutral-700 backdrop-blur hover:text-primary-600 dark:bg-neutral-800/50 dark:text-neutral dark:hover:text-primary-400" aria-label="Scroll to top" title="Scroll to top">&uarr;</a></div></main><footer class="py-10 print:hidden"><nav class="pb-4 text-base font-medium text-neutral-500 dark:text-neutral-400"><ul class="flex list-none flex-col sm:flex-row"><li class="group mb-1 ltr:text-right rtl:text-left sm:mb-0 sm:me-7 sm:last:me-0"><a href=https://git.baalajimaestro.me/baalajimaestro/personal-website/ title><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">Source Code</span></a></li><li class="group mb-1 ltr:text-right rtl:text-left sm:mb-0 sm:me-7 sm:last:me-0"><a href=https://links.baalajimaestro.me title><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">Socials/Portfolio</span></a></li><li class="group mb-1 ltr:text-right rtl:text-left sm:mb-0 sm:me-7 sm:last:me-0"><a href=https://paypal.me/baalajimaestro title><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">Donate Me</span></a></li><li class="group mb-1 ltr:text-right rtl:text-left sm:mb-0 sm:me-7 sm:last:me-0"><a href=/posts/index.xml title><span class="decoration-primary-500 group-hover:underline group-hover:decoration-2 group-hover:underline-offset-2">RSS</span></a></li></ul></nav><div class="flex items-center justify-between"><div><p class="text-sm text-neutral-500 dark:text-neutral-400">© 2023 Maestro Creativescape.</p><p class="text-xs text-neutral-500 dark:text-neutral-400">Powered by <a class="hover:underline hover:decoration-primary-400 hover:text-primary-500" href=https://gohugo.io/ target=_blank rel="noopener noreferrer">Hugo</a> & <a class="hover:underline hover:decoration-primary-400 hover:text-primary-500" href=https://git.io/hugo-congo target=_blank rel="noopener noreferrer">Congo</a></p></div></div></footer></div></body></html>