<?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: Nima jahan bakhshian</title>
    <description>The latest articles on DEV Community by Nima jahan bakhshian (@dvlpr1996).</description>
    <link>https://dev.to/dvlpr1996</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%2F2620104%2F3f0ef5ef-ec81-4188-9707-cfd9a55f817f.jpg</url>
      <title>DEV Community: Nima jahan bakhshian</title>
      <link>https://dev.to/dvlpr1996</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dvlpr1996"/>
    <language>en</language>
    <item>
      <title>Practical Git Commands Every Developer Should Know</title>
      <dc:creator>Nima jahan bakhshian</dc:creator>
      <pubDate>Sun, 06 Sep 2026 08:31:15 +0000</pubDate>
      <link>https://dev.to/dvlpr1996/practical-git-commands-every-developer-should-know-3do7</link>
      <guid>https://dev.to/dvlpr1996/practical-git-commands-every-developer-should-know-3do7</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6q5hq64b67ml76c0pqv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff6q5hq64b67ml76c0pqv.jpg" alt="git commands" width="736" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git is the most widely used version control system in the world. Whether you’re working alone or collaborating with a team, knowing the right commands can save you hours of frustration and help you work more confidently.&lt;/p&gt;

&lt;p&gt;Below is a practical collection of the most useful Git commands, organized by real-world workflows.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Getting Started
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Creates a new Git repository in the current directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Downloads an existing repository from a remote server and creates a local copy&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone &amp;lt;repository-url&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sets your identity so every commit is correctly attributed to you&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"Your Name"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"your.email@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Daily Workflow
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Check the current status of your working directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git status &lt;span class="c"&gt;# shows which files are modified, staged, or untracked&lt;/span&gt;

git status &lt;span class="nt"&gt;-sb&lt;/span&gt; &lt;span class="c"&gt;# the shorter and cleaner version&lt;/span&gt;

git add &amp;lt;file&amp;gt; &lt;span class="c"&gt;# stage a specific file&lt;/span&gt;

git add &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="c"&gt;# stage all changes&lt;/span&gt;

&lt;span class="c"&gt;# Show unstaged changes (working directory vs staging area)&lt;/span&gt;
git diff

&lt;span class="c"&gt;# Show staged changes (staging area vs last commit)&lt;/span&gt;
git diff &lt;span class="nt"&gt;--staged&lt;/span&gt;

&lt;span class="c"&gt;# Create a commit&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: add image uploader"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Working with Branches
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Switching Branches with&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git switch&lt;/code&gt; is the dedicated command for switching branches (safer and clearer than the old &lt;code&gt;git checkout&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Switch to an existing branch&lt;/span&gt;
git switch feature-branch

&lt;span class="c"&gt;# Create a new branch and switch to it in one command&lt;/span&gt;
git switch &lt;span class="nt"&gt;-c&lt;/span&gt; new-feature

git branch &lt;span class="c"&gt;# List all local branches&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4. Working with Remotes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Managing Remotes&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Show remote repositories with their fetch and push URLs&lt;/span&gt;
git remote &lt;span class="nt"&gt;-v&lt;/span&gt;

&lt;span class="c"&gt;# List remote names only&lt;/span&gt;
git remote

&lt;span class="c"&gt;# Remove a remote&lt;/span&gt;
git remote remove origin

&lt;span class="c"&gt;# Add a new remote&lt;/span&gt;
git remote add origin &amp;lt;repository-url&amp;gt;

&lt;span class="c"&gt;# Remove a remote&lt;/span&gt;
git remote remove &amp;lt;name&amp;gt;

&lt;span class="c"&gt;# Fetch latest changes without merging&lt;/span&gt;
git fetch &lt;span class="nt"&gt;--all&lt;/span&gt; &lt;span class="nt"&gt;--prune&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5. Hunting Down Bugs
&lt;/h3&gt;

&lt;p&gt;If a bug has appeared and you're not sure which commit introduced it, bisect uses binary search across your commit history&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a binary search to find which commit introduced a bug&lt;/span&gt;
git bisect start

&lt;span class="c"&gt;# Mark the current commit as bad (contains the bug)&lt;/span&gt;
git bisect bad

&lt;span class="c"&gt;# Mark a known good commit (for example version v1.0)&lt;/span&gt;
git bisect good v1.0

&lt;span class="c"&gt;# used to end a Git bisection session, clean up the bisection state&lt;/span&gt;
&lt;span class="c"&gt;# and return your working directory to the commit you were on before you started&lt;/span&gt;
git bisect reset
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  6. Undoing Changes
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Cleaning Up Untracked Files&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Dry-run: show which untracked files would be deleted (safe preview)&lt;/span&gt;
git clean &lt;span class="nt"&gt;-n&lt;/span&gt;

&lt;span class="c"&gt;# Actually delete untracked files and directories&lt;/span&gt;
git clean &lt;span class="nt"&gt;-fd&lt;/span&gt;

&lt;span class="c"&gt;# Discard changes in a specific file&lt;/span&gt;
git restore &amp;lt;file&amp;gt;

&lt;span class="c"&gt;# Discard all local uncommitted changes (dangerous)&lt;/span&gt;
git restore &lt;span class="nb"&gt;.&lt;/span&gt;
git clean &lt;span class="nt"&gt;-fd&lt;/span&gt;

&lt;span class="c"&gt;# Undo the last commit but keep the changes staged&lt;/span&gt;
git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1

&lt;span class="c"&gt;# Undo the last commit and unstage the changes&lt;/span&gt;
git reset HEAD~1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  7. Temporarily Saving Work (Stash)
&lt;/h3&gt;

&lt;p&gt;Always give a meaningful message with git stash push -m "...".&lt;/p&gt;

&lt;p&gt;After a few days stash@{0}, stash@{1} become completely useless without messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Temporarily save (stash) your uncommitted changes so you can work on something else&lt;/span&gt;
git stash

&lt;span class="c"&gt;# Save your current uncommitted work (both staged + unstaged) with a clear message&lt;/span&gt;
&lt;span class="c"&gt;# Very useful when you need to urgently switch branch or pull latest changes&lt;/span&gt;
git stash push &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"WIP: login form validation and dark mode toggle"&lt;/span&gt;

&lt;span class="c"&gt;# Apply the most recent stash and remove it from the stash list&lt;/span&gt;
git stash pop

&lt;span class="c"&gt;# List all saved stashes&lt;/span&gt;
git stash list

&lt;span class="c"&gt;# Apply a specific stash (without removing it from the list)&lt;/span&gt;
git stash apply stash@&lt;span class="o"&gt;{&lt;/span&gt;2&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# See what is inside a particular stash&lt;/span&gt;
git stash show &lt;span class="nt"&gt;-p&lt;/span&gt; stash@&lt;span class="o"&gt;{&lt;/span&gt;1&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Delete a specific stash after you're done with it&lt;/span&gt;
git stash drop stash@&lt;span class="o"&gt;{&lt;/span&gt;1&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Delete ALL stashes (use carefully)&lt;/span&gt;
git stash clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  8. Attaching Notes to Commits
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git notes&lt;/code&gt; lets you attach extra information to a commit, without changing the commit itself or its hash&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git notes add &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"This commit caused a regression in v2.3"&lt;/span&gt; &amp;lt;commit-hash&amp;gt;
git log &lt;span class="nt"&gt;--show-notes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  9. A Clean Summary of Contributors
&lt;/h3&gt;

&lt;p&gt;Instead of scrolling through a full commit log, &lt;code&gt;shortlog&lt;/code&gt; gives you a ranked summary of who committed what, and how often a quick way to generate a contribution report without external tooling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git shortlog
git shortlog &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;--all&lt;/span&gt;
git shortlog &lt;span class="nt"&gt;-sn&lt;/span&gt; &lt;span class="nt"&gt;--since&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"1 month ago"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  10. Inspect Any Single Commit in Detail
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Show the full details of a specific commit (message, author, date, and the full diff of changes)&lt;/span&gt;
git show &amp;lt;commit-hash&amp;gt;

&lt;span class="c"&gt;# Show the content of a specific file as it existed in a particular commit&lt;/span&gt;
git show &amp;lt;commit-hash&amp;gt;:path/to/file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy coding, and may your commits always be meaningful!&lt;/p&gt;

</description>
      <category>git</category>
      <category>developer</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
