<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>versioncontrol &amp;mdash; sandeepk</title>
    <link>https://blogs.dgplug.org/sandeepk/tag:versioncontrol</link>
    <description></description>
    <pubDate>Thu, 30 Apr 2026 22:19:35 +0000</pubDate>
    <item>
      <title>Git: Commands</title>
      <link>https://blogs.dgplug.org/sandeepk/git-commands</link>
      <description>&lt;![CDATA[Git is a version control tool, that helps to track changes in the project. We will discuss a few useful commands which are handy to know while working with the git&#xA;&#xA;Creating a branch with no commits on it&#xA;      git checkout --orphan branchname&#xA;      git log&#xA;fatal: your current branch &#39;branchname&#39; does not have any commits yet&#xA;&#xA;Remove stale branches&#xA;In your local, if you have branches that are removed in the remote then you can use the       git remote prune origin&#xA;&#xA;To pick a commit from another branch&#xA;If you want to pick a commit from other branches into your current branch you can use the       git cherry-pick -x commit SHA1&#xA;&#xA;To view commits that are not pushed yet&#xA;      git log @{u}..&#xA;&#xA;Run previous command&#xA;In Git, we are also switching from one branch to the other. Typing the name, again and again, is tedious. You can use       randomos git:(uselessdict) git checkout addnumbers&#xA;Switched to branch &#39;addnumbers&#39;&#xA;Your branch is up-to-date with &#39;origin/addnumbers&#39;.&#xA;      randomos git:(addnumbers) git checkout -&#xA;Switched to branch &#39;uselessdict&#39;&#xA;Your branch is up-to-date with &#39;origin/useless_dict&#39;.&#xA;&#xA;If you have any Git commands which you feel are worth sharing and can save some time. Please do share.&#xA;&#xA;Cheers!&#xA;&#xA;#100DaysToOffload  #Git #VersionControl&#xA;&#xA; ]]&gt;</description>
      <content:encoded><![CDATA[<p>Git is a version control tool, that helps to track changes in the project. We will discuss a few useful commands which are handy to know while working with the git</p>

<p><strong>Creating a branch with no commits on it</strong></p>

<pre><code class="language-bash">&gt;&gt;&gt; git checkout --orphan &lt;branch_name&gt;
&gt;&gt;&gt; git log
fatal: your current branch &#39;&lt;branch_name&gt;&#39; does not have any commits yet

</code></pre>

<p><strong>Remove stale branches</strong>
In your local, if you have branches that are removed in the remote then you can use the <code>prune</code> command to delete those branches in local also.</p>

<pre><code class="language-bash">&gt;&gt;&gt; git remote prune origin

</code></pre>

<p><strong>To pick a commit from another branch</strong>
If you want to pick a commit from other branches into your current branch you can use the <code>cherry-pick</code> command and <code>-x</code> for when recording the commit, append a line that says “(cherry picked from commit ...)” to the original commit message to indicate which commit this change was cherry-picked from.</p>

<pre><code class="language-bash">&gt;&gt;&gt; git cherry-pick -x &lt;commit SHA1&gt;

</code></pre>

<p><strong>To view commits that are not pushed yet</strong></p>

<pre><code class="language-bash">&gt;&gt;&gt; git log @{u}..

</code></pre>

<p><strong>Run previous command</strong>
In Git, we are also switching from one branch to the other. Typing the name, again and again, is tedious. You can use <code>-</code> with the Git command, to save your self from typing the name again</p>

<pre><code class="language-bash">&gt;&gt;&gt;  randomos git:(useless_dict) git checkout add_numbers
Switched to branch &#39;add_numbers&#39;
Your branch is up-to-date with &#39;origin/add_numbers&#39;.
&gt;&gt;&gt;  randomos git:(add_numbers) git checkout -
Switched to branch &#39;useless_dict&#39;
Your branch is up-to-date with &#39;origin/useless_dict&#39;.

</code></pre>

<p>If you have any Git commands which you feel are worth sharing and can save some time. Please do share.</p>

<p>Cheers!</p>

<p><a href="/sandeepk/tag:100DaysToOffload" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">100DaysToOffload</span></a>  <a href="/sandeepk/tag:Git" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Git</span></a> <a href="/sandeepk/tag:VersionControl" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">VersionControl</span></a></p>
]]></content:encoded>
      <guid>https://blogs.dgplug.org/sandeepk/git-commands</guid>
      <pubDate>Wed, 21 Apr 2021 03:06:58 +0000</pubDate>
    </item>
  </channel>
</rss>