<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bharath Adithya</title>
    <description>The latest articles on DEV Community by Bharath Adithya (@bharath_adithya).</description>
    <link>https://dev.to/bharath_adithya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4100713%2F4b453590-fc4d-4e5f-b400-b414fe2b57aa.jpeg</url>
      <title>DEV Community: Bharath Adithya</title>
      <link>https://dev.to/bharath_adithya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bharath_adithya"/>
    <language>en</language>
    <item>
      <title># 10 Git Commands That Made Me More Confident With Git</title>
      <dc:creator>Bharath Adithya</dc:creator>
      <pubDate>Sat, 29 Aug 2026 20:06:16 +0000</pubDate>
      <link>https://dev.to/bharath_adithya/-10-git-commands-that-made-me-more-confident-with-git-47h9</link>
      <guid>https://dev.to/bharath_adithya/-10-git-commands-that-made-me-more-confident-with-git-47h9</guid>
      <description>&lt;p&gt;If you've used Git for a while, you probably know the basics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add
git commit
git pull
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands are enough to get started.&lt;/p&gt;

&lt;p&gt;But as your projects become bigger and you start working with branches, pull requests, conflicts, and other developers, Git starts getting a little more interesting.&lt;/p&gt;

&lt;p&gt;Here are &lt;strong&gt;10 Git commands and techniques that I found especially useful for moving beyond the basics.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;code&gt;git merge&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Let's say you have a feature branch and the &lt;code&gt;main&lt;/code&gt; branch has received some new changes.&lt;/p&gt;

&lt;p&gt;You can bring those changes into your current branch using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git merge main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simplified history might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C main
     \
      D---E feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After merging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C------M
     \        /
      D---E---
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;M&lt;/code&gt; is the merge commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  When is merge useful?
&lt;/h3&gt;

&lt;p&gt;Use merge when you want to preserve the branch history and clearly show that two lines of development were combined.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. &lt;code&gt;git rebase&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Rebase takes a different approach.&lt;/p&gt;

&lt;p&gt;Instead of creating a merge commit, Git moves your commits and reapplies them on top of another branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The previous history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C main
     \
      D---E feature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can become:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D'---E'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is often easier to read.&lt;/p&gt;

&lt;p&gt;But there's an important thing to remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rebase rewrites commit history.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So a simple rule is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rebase your own local work carefully, especially before sharing it with others.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're rebasing a shared branch, you can create unnecessary problems for teammates.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;code&gt;git commit --amend&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Ever made a commit and immediately realized you forgot one small change?&lt;/p&gt;

&lt;p&gt;Instead of creating another unnecessary commit, you can add the change to the previous commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git add forgotten-file.js
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt; &lt;span class="nt"&gt;--no-edit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--no-edit&lt;/code&gt; option keeps your previous commit message.&lt;/p&gt;

&lt;p&gt;If you also want to change the message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Important
&lt;/h3&gt;

&lt;p&gt;Amending creates a new commit, which means the commit hash changes.&lt;/p&gt;

&lt;p&gt;So this is safest when the commit hasn't already been shared with other people.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;git push --force-with-lease&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes you rewrite your local history using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;rebase&lt;/li&gt;
&lt;li&gt;amend&lt;/li&gt;
&lt;li&gt;interactive rebase&lt;/li&gt;
&lt;li&gt;squash&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then a normal push may be rejected.&lt;/p&gt;

&lt;p&gt;You might be tempted to use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But there's a safer option:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference is important.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--force&lt;/code&gt; basically says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Replace the remote branch with my version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;--force-with-lease&lt;/code&gt; checks whether the remote branch has changed before replacing it.&lt;/p&gt;

&lt;p&gt;That makes it a much safer choice when you actually need to force-push.&lt;/p&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;git rebase -i&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This is one of my favorite Git commands for cleaning up commits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This lets you interact with your last five commits.&lt;/p&gt;

&lt;p&gt;You'll see something similar to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick a111111 Add login page
pick b222222 Add validation
pick c333333 Fix typo
pick d444444 Fix validation
pick e555555 Remove debug code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can change &lt;code&gt;pick&lt;/code&gt; to commands such as:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;pick&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Keep the commit as it is.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;reword&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Change only the commit message.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;edit&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Pause at that commit so you can modify it.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;squash&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Combine the commit with the previous one while keeping its commit message available for editing.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;fixup&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Combine the commit with the previous one and discard its commit message.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;drop&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Remove the commit.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pick   a111111 Add login page
fixup  b222222 Fix typo
fixup  c333333 Remove debug code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can turn several messy commits into a much cleaner history.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;git stash&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine you're working on a feature and suddenly need to switch to another task.&lt;/p&gt;

&lt;p&gt;Your current code isn't ready to commit yet.&lt;/p&gt;

&lt;p&gt;That's where &lt;code&gt;git stash&lt;/code&gt; helps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git temporarily stores your uncommitted changes and gives you a clean working directory.&lt;/p&gt;

&lt;p&gt;You can then switch branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git switch main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later, you can bring your changes back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Include untracked files
&lt;/h3&gt;

&lt;p&gt;If you've also created new files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash &lt;span class="nt"&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even give your stash a useful name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash push &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"WIP authentication feature"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see your stashes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To restore one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash apply stash@&lt;span class="o"&gt;{&lt;/span&gt;0&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash pop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The simple difference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apply = restore the changes
pop   = restore + remove the stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  7. &lt;code&gt;git cherry-pick&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Sometimes you don't need an entire branch.&lt;/p&gt;

&lt;p&gt;You only need &lt;strong&gt;one specific commit&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That's where cherry-pick comes in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cherry-pick a1b2c3d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git takes the changes from that commit and applies them to your current branch.&lt;/p&gt;

&lt;p&gt;This is useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A bug fix exists on another branch&lt;/li&gt;
&lt;li&gt;You need one specific feature&lt;/li&gt;
&lt;li&gt;You don't want to merge the entire branch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One important detail:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cherry-pick creates a new commit with a different hash.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  8. &lt;code&gt;git reset&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git reset&lt;/code&gt; is useful when you want to move your branch backwards.&lt;/p&gt;

&lt;p&gt;There are three common versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--mixed&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The easiest way to remember them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;--soft  → keep changes staged
--mixed → keep changes unstaged
--hard  → discard the changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;/p&gt;

&lt;h3&gt;
  
  
  Soft reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes the last commit but keeps its changes staged.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mixed reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Removes the last commit and keeps the changes in your working directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hard reset
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moves the branch backwards and removes the changes from the working tree.&lt;/p&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Be careful with &lt;code&gt;--hard&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you understand what you're about to discard before using it.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. &lt;code&gt;git reflog&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This command can be extremely useful when you think you've lost a commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While &lt;code&gt;git log&lt;/code&gt; shows your reachable commit history, &lt;code&gt;reflog&lt;/code&gt; records movements of references such as &lt;code&gt;HEAD&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You might see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;e35fa12 HEAD@{0}: reset: moving to HEAD~2
821cd77 HEAD@{1}: commit: Add authentication
f992ab1 HEAD@{2}: commit: Add login page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That previously "lost" commit may still be accessible.&lt;/p&gt;

&lt;p&gt;Instead of immediately resetting everything again, you can create a recovery branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch rescue 821cd77
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then inspect it safely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remember
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;reflog&lt;/code&gt; isn't a magic backup.&lt;/p&gt;

&lt;p&gt;If your work was never committed or otherwise stored by Git, reflog cannot recover it.&lt;/p&gt;




&lt;h2&gt;
  
  
  10. &lt;code&gt;git revert&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Here's an important situation.&lt;/p&gt;

&lt;p&gt;You pushed a commit to a shared branch, and that commit introduced a problem.&lt;/p&gt;

&lt;p&gt;Should you rewrite the branch history?&lt;/p&gt;

&lt;p&gt;Usually, &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Suppose your history is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And &lt;code&gt;C&lt;/code&gt; introduced the problem.&lt;/p&gt;

&lt;p&gt;Running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;creates another commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A---B---C---D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;D&lt;/code&gt; contains the opposite changes needed to undo &lt;code&gt;C&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The original commit remains visible in history.&lt;/p&gt;

&lt;p&gt;That's why &lt;code&gt;revert&lt;/code&gt; is generally a better choice for undoing changes on shared branches.&lt;/p&gt;




&lt;h1&gt;
  
  
  Quick Cheat Sheet
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Main purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git merge&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Combine branch histories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git rebase&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reapply commits on top of another branch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git commit --amend&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Modify the previous commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git push --force-with-lease&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Safer force push&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git rebase -i&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clean up recent commits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git stash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Temporarily save unfinished changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git cherry-pick&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Apply one specific commit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reset&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Move branch history backwards&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reflog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find previous HEAD/reference states&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git revert&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Safely undo a shared commit&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Git becomes much easier once you stop thinking of it as just a collection of commands and start understanding &lt;strong&gt;what happens to your repository history after each command&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you're currently learning Git, I'd recommend becoming comfortable with these first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
git merge
git rebase
git revert
git reset
git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then gradually add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt;
git cherry-pick
git commit &lt;span class="nt"&gt;--amend&lt;/span&gt;
git push &lt;span class="nt"&gt;--force-with-lease&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The more you understand Git's history, the less scary those inevitable conflicts and mistakes become.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which Git command has saved you the most time?&lt;/strong&gt; 👇&lt;/p&gt;

&lt;h1&gt;
  
  
  git #beginners #programming #webdev
&lt;/h1&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>beginners</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
