<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GIT & GITHub]]></title><description><![CDATA[GIT & GITHub]]></description><link>https://git-scm.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 31 Aug 2026 13:01:49 GMT</lastBuildDate><atom:link href="https://git-scm.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Git Commands Every DevOps Engineer Should Master]]></title><description><![CDATA[Hello, tech enthusiasts! 👋 Git is the backbone of modern development and a critical tool for DevOps engineers. Whether you're managing configuration files, deploying code, or troubleshooting a production issue, a strong grasp of Git is essential. Th...]]></description><link>https://git-scm.hashnode.dev/the-most-used-git-commands-a-categorized-guide</link><guid isPermaLink="true">https://git-scm.hashnode.dev/the-most-used-git-commands-a-categorized-guide</guid><category><![CDATA[most-used-git-commands]]></category><category><![CDATA[Git Commands]]></category><category><![CDATA[Gitcommands]]></category><category><![CDATA[git commands for beginners]]></category><category><![CDATA[basic git commands]]></category><category><![CDATA[#Git & GitHub]]></category><dc:creator><![CDATA[Divakar Chakali]]></dc:creator><pubDate>Fri, 08 Aug 2025 03:01:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754621702365/4fc4d870-8b3f-4a36-9df5-d8800b11d9eb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, tech enthusiasts! 👋 Git is the backbone of modern development and a critical tool for DevOps engineers. Whether you're managing configuration files, deploying code, or troubleshooting a production issue, a strong grasp of Git is essential. This guide covers the most important Git commands for DevOps, along with their parameters and examples.</p>
<hr />
<h2 id="heading-git-repository-and-configuration">Git Repository and Configuration</h2>
<p>These are the fundamental commands for setting up and configuring a Git repository.</p>
<ul>
<li><p><strong><code>git init</code></strong></p>
<ul>
<li>Initializes a new Git repository in your current directory. This is the first step to start versioning your project.</li>
<li><strong>Example:</strong> <code>git init</code></li>
</ul>
</li>
<li><p><strong><code>git config</code></strong></p>
<ul>
<li>Used to set up your user information globally or for a specific repository.</li>
<li><strong>Parameters:</strong> <code>--global user.name</code> and <code>--global user.mail</code></li>
<li><strong>Example:</strong><pre><code class="lang-bash"><span class="hljs-comment"># Highlight text to see the hidden content</span>
git config --global user.name <span class="hljs-string">"Your Name"</span>
git config --global user.email <span class="hljs-string">"your.email@example.com"</span>
</code></pre>
</li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-committing-and-managing-changes">Committing and Managing Changes</h2>
<p>These commands are at the core of Git's version control.</p>
<ul>
<li><p><strong><code>git status</code></strong></p>
<ul>
<li>Displays the state of your working directory and staging area, showing which files are modified, staged, or untracked.</li>
<li><strong>Example:</strong> <code>git status</code></li>
</ul>
</li>
<li><p><strong><code>git add &lt;filename&gt;</code></strong></p>
<ul>
<li>Adds a file to the staging area, preparing it to be included in the next commit.</li>
<li><strong>Example:</strong> <code>git add app.js</code></li>
</ul>
</li>
<li><p><strong><code>git rm --cached &lt;filename&gt;</code></strong></p>
<ul>
<li>Unstages a file without deleting it from your working directory.</li>
<li><strong>Example:</strong> <code>git rm --cached sensitive_data.json</code></li>
</ul>
</li>
<li><p><strong><code>git commit</code></strong></p>
<ul>
<li>Saves your staged changes to the local repository as a new commit.</li>
<li><strong>Parameters:</strong><ul>
<li><code>-m "&lt;message&gt;"</code>: The most common way to add a commit message.</li>
<li><code>--amend --author "&lt;name&gt; &lt;email&gt;"</code>: Changes the author of the last commit.</li>
<li><code>--amend -m "&lt;new_message&gt;"</code>: Edits the commit message of the last commit.</li>
<li><code>--amend --no-edit</code>: Adds new staged files to the last commit without changing the message.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git commit -m "feat: Add new deployment script"</code></li>
</ul>
</li>
<li><p><strong><code>git restore --staged &lt;file&gt;</code></strong></p>
<ul>
<li>Removes a file from the staging area, moving it back to the working directory. A useful command to undo a <code>git add</code>.</li>
<li><strong>Example:</strong> <code>git restore --staged config.yaml</code></li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-viewing-history-and-undoing-changes">Viewing History and Undoing Changes</h2>
<p>For DevOps, understanding the history of a repository is key to debugging and reverting changes.</p>
<ul>
<li><p><strong><code>git log</code></strong></p>
<ul>
<li>Displays the commit history.</li>
<li><strong>Parameters:</strong><ul>
<li><code>--oneline</code>: Shows a condensed, single-line summary of each commit.</li>
<li><code>--graph --all</code>: Visualizes the branching and merging history.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git log --oneline --graph</code></li>
</ul>
</li>
<li><p><strong><code>git show &lt;commit_id&gt;</code></strong></p>
<ul>
<li>Shows the detailed changes for a specific commit, including the diff.</li>
<li><strong>Example:</strong> <code>git show a1b2c3d</code></li>
</ul>
</li>
<li><p><strong><code>git diff</code></strong></p>
<ul>
<li>Shows the changes between commits, branches, or files.</li>
<li><strong>Parameters:</strong><ul>
<li><code>&lt;commit1&gt; &lt;commit2&gt;</code>: Shows the changes between two commits.</li>
<li><code>--staged</code>: Shows changes in the staging area that are not yet committed.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git diff HEAD~1 HEAD</code></li>
</ul>
</li>
<li><p><strong><code>git reset</code></strong></p>
<ul>
<li>A powerful command to undo commits. It's crucial to understand the difference between its modes.</li>
<li><strong>Parameters:</strong><ul>
<li><code>--hard HEAD~1</code>: Deletes the last commit and discards the changes from both the staging area and the working directory. <strong>Use with caution!</strong></li>
<li><code>--soft HEAD~1</code>: Deletes the last commit but keeps the changes in the staging area. This is useful for rewriting a commit.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git reset --hard HEAD~1</code></li>
</ul>
</li>
<li><p><strong><code>git reflog</code></strong></p>
<ul>
<li>A safety net for your repository. It records every time the <code>HEAD</code> pointer is updated, allowing you to find lost commits and revert back to a previous state, even after a hard reset.</li>
<li><strong>Example:</strong> <code>git reflog</code></li>
</ul>
</li>
<li><p><strong><code>git revert &lt;commit_id&gt;</code></strong></p>
<ul>
<li>Creates a new commit that undoes the changes of a specified commit. This is a safer way to "undo" a commit because it doesn't rewrite history and is better for shared branches.</li>
<li><strong>Example:</strong> <code>git revert b4c5d6e</code></li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-branching-and-merging">Branching and Merging</h2>
<p>Branching is fundamental to collaborative development and release management.</p>
<ul>
<li><p><strong><code>git branch</code></strong></p>
<ul>
<li><strong>Parameter-less:</strong> Lists all local branches.</li>
<li><strong>With a name:</strong> Creates a new branch.</li>
<li><strong>Example:</strong> <code>git branch new-feature</code></li>
</ul>
</li>
<li><p><strong><code>git checkout</code></strong></p>
<ul>
<li>Switches to a different branch.</li>
<li><strong>Parameter:</strong> <code>-b &lt;branchname&gt;</code>: Creates and switches to a new branch in one command.</li>
<li><strong>Example:</strong> <code>git checkout -b hotfix/critical-bug</code></li>
</ul>
</li>
<li><p><strong><code>git merge</code></strong></p>
<ul>
<li>Merges the changes from a specified branch into your current branch.</li>
<li><strong>Example:</strong> <code>git merge new-feature</code></li>
</ul>
</li>
<li><p><strong><code>git branch -d &lt;branchname&gt;</code></strong></p>
<ul>
<li>Safely deletes a local branch. It will prevent you from deleting a branch that has unmerged commits.</li>
<li><strong>Example:</strong> <code>git branch -d old-branch</code></li>
</ul>
</li>
<li><p><strong><code>git branch -D &lt;branchname&gt;</code></strong></p>
<ul>
<li>Forcefully deletes a local branch, even if it has unmerged commits. Use this when you are sure you no longer need the commits.</li>
<li><strong>Example:</strong> <code>git branch -D temporary-branch</code></li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-advanced-operations-and-cleanup">Advanced Operations and Cleanup</h2>
<p>These commands are for more advanced workflows, particularly useful for maintaining a clean and efficient repository.</p>
<ul>
<li><p><strong><code>git cherry-pick &lt;commit_id&gt;</code></strong></p>
<ul>
<li>Applies the changes from a specific commit onto your current branch. This is useful for backporting a hotfix from one branch to another without merging the entire branch.</li>
<li><strong>Example:</strong> <code>git cherry-pick c7d8e9f</code></li>
</ul>
</li>
<li><p><strong><code>git clean</code></strong></p>
<ul>
<li>Removes untracked files from your working directory. This is useful for cleaning up build artifacts or temporary files.</li>
<li><strong>Parameters:</strong><ul>
<li><code>-n</code>: Shows which files would be deleted without actually deleting them (a dry run).</li>
<li><code>-f</code>: Forcefully removes the untracked files.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git clean -n</code></li>
</ul>
</li>
<li><p><strong><code>git update-ref -d HEAD</code></strong></p>
<ul>
<li>Deletes the <code>HEAD</code> pointer, effectively un-initializing your Git repository while keeping the files and folders. This is an advanced and potentially dangerous command.</li>
<li><strong>Example:</strong> <code>git update-ref -d HEAD</code></li>
</ul>
</li>
</ul>
<hr />
<h2 id="heading-remote-repositories-and-tagging">Remote Repositories and Tagging</h2>
<p>These commands are used to interact with remote repositories and manage versioning.</p>
<ul>
<li><p><strong><code>git remote</code></strong></p>
<ul>
<li><strong>Parameter:</strong> <code>add origin &lt;url&gt;</code>: Adds a remote repository URL to your local repo.</li>
<li><strong>Parameter:</strong> <code>-v</code>: Lists the remote repositories your local repo is connected to.</li>
<li><strong>Example:</strong> <code>git remote add origin https://github.com/my-org/my-app.git</code></li>
</ul>
</li>
<li><p><strong><code>git push</code></strong></p>
<ul>
<li>Sends your local commits to the remote repository.</li>
<li><strong>Parameters:</strong><ul>
<li><code>origin &lt;branch&gt;</code>: Pushes a specific branch.</li>
<li><code>--all</code>: Pushes all local branches to the remote.</li>
<li><code>--delete &lt;branchname&gt;</code>: Deletes a branch on the remote repository.</li>
</ul>
</li>
<li><strong>Example:</strong> <code>git push origin --delete feature/old-feature</code></li>
</ul>
</li>
<li><p><strong><code>git pull</code></strong></p>
<ul>
<li>Fetches changes from the remote repository and merges them into your current branch.</li>
<li><strong>Example:</strong> <code>git pull origin main</code></li>
</ul>
</li>
<li><p><strong><code>git fetch</code></strong></p>
<ul>
<li>Downloads commits, files, and refs from a remote repository into your local repository without merging. This lets you see what changes others have made before you pull them.</li>
<li><strong>Example:</strong> <code>git fetch origin</code></li>
</ul>
</li>
<li><p><strong><code>git tag</code></strong></p>
<ul>
<li>Creates a tag to mark a significant point in your repository's history, such as a release version.</li>
<li><strong>Example:</strong> <code>git tag v1.0.0</code></li>
<li><strong>Pushing tags:</strong> <code>git push origin v1.0.0</code> or <code>git push origin --tags</code></li>
</ul>
</li>
</ul>
<p>These commands form the foundation of a robust Git workflow for any DevOps professional. Mastering them will help you maintain a clean, stable, and efficient CI/CD pipeline.</p>
]]></content:encoded></item><item><title><![CDATA[Git vs. GitHub and the History of Version Control]]></title><description><![CDATA[What is Git?
Git is a free and open-source, distributed version control system (DVCS). In simpler terms, it's a powerful tool that helps you manage changes to files and projects over time. Imagine it as a highly intelligent "save" button for your ent...]]></description><link>https://git-scm.hashnode.dev/git-vs-github-understanding-the-core-tool-and-the-collaboration-platform</link><guid isPermaLink="true">https://git-scm.hashnode.dev/git-vs-github-understanding-the-core-tool-and-the-collaboration-platform</guid><category><![CDATA[#Git & GitHub]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[#githistory]]></category><dc:creator><![CDATA[Divakar Chakali]]></dc:creator><pubDate>Mon, 04 Aug 2025 15:59:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754623279985/3001e176-7e37-4ac2-bf36-4cbb2d1ef6fe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-git">What is Git?</h2>
<p><strong>Git</strong> is a <strong>free and open-source, distributed version control system (DVCS)</strong>. In simpler terms, it's a powerful tool that helps you manage changes to files and projects over time. Imagine it as a highly intelligent "save" button for your entire project, meticulously keeping a detailed history of every modification, who made it, and why.</p>
<p>While most commonly associated with software development and source code management, Git is versatile enough to track changes in any set of files (e.g., documents, website assets, design files).</p>
<p><strong>Key characteristics of Git:</strong></p>
<ul>
<li><strong>Version Control:</strong> It precisely tracks changes to files and directories, allowing you to revert to previous versions, compare changes side-by-side, and observe the entire evolution of your project.</li>
<li><strong>Distributed:</strong> This is a fundamental differentiator. Unlike older, centralized version control systems (like SVN or CVS) that rely on a single central server for the complete history, Git provides <strong>every developer with a full local copy of the entire repository</strong> (including its complete history). This offers significant advantages:<ul>
<li>You can work entirely offline.</li>
<li>Operations such as committing, branching, and merging are exceptionally fast because they execute locally.</li>
<li>There's no single point of failure; if a "central" server goes down, every developer retains a complete backup.</li>
</ul>
</li>
<li><strong>Speed and Efficiency:</strong> Git is engineered for speed, performing efficiently even with very large projects and a high volume of changes.</li>
<li><strong>Branching and Merging:</strong> Git makes it incredibly easy and "cheap" (in terms of resources and complexity) to create "branches" (separate lines of development) and subsequently merge them back into the main project. This empowers parallel work among team members and facilitates experimentation without impacting the stable codebase.</li>
<li><strong>Data Integrity:</strong> Git employs SHA-1 hashing to secure the content of files, directories, versions, and commits. This cryptographic checksum ensures the authenticity of the history and guards against accidental or malicious alteration.</li>
</ul>
<hr />
<h2 id="heading-evolution-of-version-control-systems-a-historical-view">Evolution of Version Control Systems: A Historical View</h2>
<p>To truly appreciate Git, you have to understand the journey of version control. The problems that previous systems faced directly led to Git's design.</p>
<h3 id="heading-source-code-control-management-sccs">Source Code Control Management (SCCS)</h3>
<ul>
<li><strong>Concept:</strong> These early systems were designed to track changes in <strong>single files</strong>.</li>
<li><strong>Drawback:</strong> They were not built for multiple files or directories, making them unsuitable for managing entire projects.</li>
</ul>
<h3 id="heading-revision-control-system-rcs">Revision Control System (RCS)</h3>
<ul>
<li><strong>Concept:</strong> An improvement over SCCS, RCS could track changes across <strong>multiple files</strong> within a project.</li>
<li><strong>Drawback:</strong> It still didn't have the ability to track an entire project's directory structure, which is a fundamental requirement for modern software.</li>
</ul>
<h3 id="heading-concurrent-version-control-system-cvs">Concurrent Version Control System (CVS)</h3>
<ul>
<li><strong>Concept:</strong> This was a huge leap forward, allowing <strong>multiple users</strong> to work on the same files and directories at the same time. It's considered the first major step toward collaborative development.</li>
<li><strong>Drawback:</strong> It was a <strong>centralized</strong> system, prone to repository corruption, and its branching and merging capabilities were often clunky.</li>
</ul>
<h3 id="heading-subversion-svn">Subversion (SVN)</h3>
<ul>
<li><strong>Concept:</strong> Designed as a "better CVS," SVN was also a <strong>centralized system</strong> that improved on CVS's weaknesses. It could track changes to files and folders for multiple users and was much more stable.</li>
<li><strong>Drawback:</strong> As a centralized system, it still had a <strong>single point of failure</strong>. If the central server went down, developers couldn't commit changes or access project history, and working offline was difficult.</li>
</ul>
<h3 id="heading-git-distributed-version-control-system">Git (Distributed Version Control System)</h3>
<ul>
<li><strong>Concept:</strong> Git was the revolutionary answer to the problems of centralized systems. It's a <strong>distributed version control system</strong> that gives every user a full, local copy of the entire repository, including its complete history.</li>
<li><strong>Advantage:</strong> Git eliminates the single point of failure, is incredibly fast because most operations are local, and has a robust branching and merging model that makes it the industry standard today.</li>
</ul>
<p>This evolution shows a clear trend: from single-user, single-file management to a fully distributed system that prioritizes speed, collaboration, and data integrity.</p>
<hr />
<h2 id="heading-history-of-git">History of Git</h2>
<p>Git was created by <strong>Linus Torvalds</strong>, the renowned architect behind the Linux operating system kernel. The origin story of Git is directly tied to the specific needs of the Linux kernel development.</p>
<ul>
<li><strong>The Problem (Pre-2005):</strong> For several years, the Linux kernel project, a monumental open-source collaborative effort, depended on a proprietary (closed-source) Distributed Version Control System named <strong>BitKeeper</strong>. This tool was provided without charge to open-source projects.</li>
<li><strong>The Dispute (2005):</strong> In 2005, a disagreement emerged between the Linux kernel community and BitKeeper's parent company. This unfortunate event led to the revocation of the free license for Linux developers.</li>
<li><strong>The Urgent Need for a New Solution:</strong> The Linux kernel project found itself suddenly without a suitable version control system that could meet its demands for scale, distributed nature, and adherence to the open-source philosophy. Linus Torvalds, known for his pragmatic and direct approach, made the decision to write a new tool from scratch.</li>
<li><strong>Rapid Development:</strong> Torvalds outlined key objectives for this new VCS:<ul>
<li><strong>Speed:</strong> It had to be exceptionally fast.</li>
<li><strong>Simple design:</strong> Its core should be easy to understand and implement.</li>
<li><strong>Strong support for non-linear development:</strong> Crucial for thousands of developers working concurrently on diverse features.</li>
<li><strong>Fully distributed:</strong> No dependence on a single central server.</li>
<li><strong>Ability to handle large projects:</strong> Specifically, the Linux kernel itself.</li>
<li>Remarkably, Torvalds developed a working prototype of Git in <strong>less than a week</strong> in April 2005. Within just one month, Git was already managing the Linux kernel's vast source code.</li>
</ul>
</li>
<li><strong>Evolution and Widespread Adoption:</strong> While Torvalds initiated the project, the open-source community quickly contributed, with Junio Hamano becoming the primary maintainer soon after its inception. Git rapidly gained momentum and, by the 2010s, firmly established itself as the <strong>de facto standard</strong> for version control in software development globally.</li>
</ul>
<p>The name "Git" itself, as explained by Torvalds, was British slang for a "silly or contemptible person," a somewhat self-deprecating and unconventional choice that aligned with his personality.</p>
<hr />
<h2 id="heading-how-git-differentiates-from-github">How Git Differentiates from GitHub</h2>
<p>This is a common point of confusion for newcomers. The key distinction is fundamental:</p>
<p><strong>Git is the <em>tool</em> (the underlying technology/software), while GitHub is a <em>service</em> (a platform built on top of that tool).</strong></p>
<p>You can think of it using this analogy:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td><strong>Git (The Tool/Technology)</strong></td><td><strong>GitHub (The Service/Platform)</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>What it is</strong></td><td>A <strong>Distributed Version Control System (DVCS)</strong> software.</td><td>A <strong>cloud-based hosting service for Git repositories</strong> with extensive collaboration features.</td></tr>
<tr>
<td><strong>Location</strong></td><td>Installed <strong>locally</strong> on your computer.</td><td>Accessed via a <strong>web browser</strong> (or specific desktop applications) in the cloud.</td></tr>
<tr>
<td><strong>Functionality</strong></td><td>Tracks changes, manages versions, handles branching/merging, maintains commit history. It's the "engine" that powers version control.</td><td>Hosts Git repositories online, provides a web-based Graphical User Interface (GUI), and adds collaborative/social features. It's the "social network" or "central hub" for Git projects.</td></tr>
<tr>
<td><strong>Required</strong></td><td>You <strong>can use Git without GitHub</strong>.</td><td>You <strong>cannot use GitHub without Git</strong>. GitHub relies entirely on Git for its core functionality.</td></tr>
<tr>
<td><strong>Access</strong></td><td>Works fully <strong>offline</strong> once the repository is cloned.</td><td>Requires an <strong>internet connection</strong> for most operations (e.g., pushing local changes, pulling updates, interacting with issues).</td></tr>
<tr>
<td><strong>Interface</strong></td><td>Primarily a <strong>command-line interface (CLI)</strong> tool. Git also offers basic built-in GUIs (like Git GUI, Gitk).</td><td>Primarily a <strong>Graphical User Interface (GUI)</strong> accessible via its website. Also offers desktop applications like GitHub Desktop.</td></tr>
<tr>
<td><strong>Collaboration</strong></td><td>Enables distributed collaboration at a technical level, but doesn't inherently provide project management, issue tracking, or social networking features.</td><td>Facilitates robust collaboration with features like: \- <strong>Pull Requests</strong> (for code review and discussion)\- <strong>Issue Tracking</strong>\- <strong>Project Boards</strong>\- <strong>Wikis</strong>\- User management and permissions\- Integrations with other development tools (e.g., CI/CD pipelines)</td></tr>
<tr>
<td><strong>Ownership</strong></td><td>Free and open-source software, maintained by the Linux community.</td><td>Commercial company (owned by Microsoft since 2018). Offers free plans for public repositories and basic private ones, with paid plans for advanced features and larger private projects.</td></tr>
</tbody>
</table>
</div><p><strong>In essence:</strong></p>
<ul>
<li>You use <strong>Git</strong> on your local machine to perform all your version control tasks: tracking code changes, creating new branches, making commits, and merging code.</li>
<li>You use <strong>GitHub</strong> (or similar platforms like GitLab or Bitbucket) to push your local Git repositories to a central online location, share them with team members, collaborate on projects, conduct code reviews, manage issues, and build a public or private portfolio of your work.</li>
</ul>
<p>Most modern software development teams effectively utilize <strong>both</strong>: Git for the fundamental version control operations locally, and a platform like GitHub as a central hub for hosting, collaboration, and comprehensive project management.</p>
]]></content:encoded></item></channel></rss>