<?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: Lucas Braun</title>
    <description>The latest articles on DEV Community by Lucas Braun (@lbraun7).</description>
    <link>https://dev.to/lbraun7</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3829880%2Ff4297eea-e1d7-4a1a-b529-f86e52351c2d.jpg</url>
      <title>DEV Community: Lucas Braun</title>
      <link>https://dev.to/lbraun7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lbraun7"/>
    <language>en</language>
    <item>
      <title>Git beyond push: the commands nobody taught you</title>
      <dc:creator>Lucas Braun</dc:creator>
      <pubDate>Fri, 10 Apr 2026 13:30:28 +0000</pubDate>
      <link>https://dev.to/lbraun7/git-beyond-push-the-commands-nobody-taught-you-1n0i</link>
      <guid>https://dev.to/lbraun7/git-beyond-push-the-commands-nobody-taught-you-1n0i</guid>
      <description>&lt;p&gt;Everyone learns Git the same way: &lt;code&gt;git init&lt;/code&gt;, &lt;code&gt;git add .&lt;/code&gt;, &lt;code&gt;git commit -m "first commit"&lt;/code&gt;, &lt;code&gt;git push&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And then just... stops there.&lt;/p&gt;

&lt;p&gt;The problem is that Git has a huge set of commands that make a real difference day-to-day — and almost no beginner tutorial ever mentions them. You only find out about them when something breaks, at 11pm, with an open pull request.&lt;/p&gt;

&lt;p&gt;This article is here to change that.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;code&gt;git stash&lt;/code&gt; — Git's secret pocket
&lt;/h2&gt;

&lt;p&gt;You're in the middle of a feature, the code is half-done, and you get a message: &lt;em&gt;"there's an urgent bug to fix on main"&lt;/em&gt;. What do you do?&lt;/p&gt;

&lt;p&gt;If you try &lt;code&gt;git checkout&lt;/code&gt; like that, Git will complain. If you make a commit, you'll pollute your history with a "WIP: saving to switch branches".&lt;/p&gt;

&lt;p&gt;The solution is &lt;code&gt;stash&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;git stash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This saves all your uncommitted changes to a temporary place and leaves your working directory clean. Fix the bug, come back, and restore:&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;Want to see what you have saved?&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;You can have multiple stashes and give them names:&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;-m&lt;/span&gt; &lt;span class="s2"&gt;"login feature halfway done"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. &lt;code&gt;git log --oneline&lt;/code&gt; — because the default log is terrible
&lt;/h2&gt;

&lt;p&gt;Ever opened a &lt;code&gt;git log&lt;/code&gt; and stared at a massive wall of text? There's a much better way:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a3f1c2e feat: add JWT authentication
9b2d441 fix: correct form validation
3c8e109 chore: update dependencies
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clean, readable, one commit per line.&lt;/p&gt;

&lt;p&gt;Want to see branches too?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git log &lt;span class="nt"&gt;--oneline&lt;/span&gt; &lt;span class="nt"&gt;--graph&lt;/span&gt; &lt;span class="nt"&gt;--all&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This draws a visual tree of your branches in the terminal. Looks like something from a hacker movie, but it's just Git.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;code&gt;git diff&lt;/code&gt; — before committing, see what you actually changed
&lt;/h2&gt;

&lt;p&gt;You know that moment when you type &lt;code&gt;git add .&lt;/code&gt; without even checking what changed? Yeah, everyone does it. But the right way is to review 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 diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This shows &lt;strong&gt;line by line&lt;/strong&gt; what changed in files that haven't been staged yet.&lt;/p&gt;

&lt;p&gt;Already ran &lt;code&gt;git add&lt;/code&gt; and want to review before committing?&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Want to compare two specific 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 diff abc1234 def5678
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reviewing your diff becomes a habit once you stop accidentally committing garbage.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;git commit --amend&lt;/code&gt; — fixing your last commit
&lt;/h2&gt;

&lt;p&gt;Committed with the wrong message? Forgot to include a file? You don't need to create a new commit just for that:&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;p&gt;This opens your editor with the last commit message for you to edit. Save, close, done.&lt;/p&gt;

&lt;p&gt;Want to change the message directly without opening the editor?&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;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: add JWT authentication"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to include a forgotten file?&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.py
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;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Warning:&lt;/strong&gt; only use &lt;code&gt;--amend&lt;/code&gt; on commits that &lt;strong&gt;haven't been pushed to the remote yet&lt;/strong&gt;. If you've already pushed, you'll run into trouble pushing again.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;git restore&lt;/code&gt; — undoing changes without drama
&lt;/h2&gt;

&lt;p&gt;You changed a file and regretted it. Want to go back to how it was at the last 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 restore filename.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This discards all local changes in that file. No commit, no hassle.&lt;/p&gt;

&lt;p&gt;Want to undo a &lt;code&gt;git add&lt;/code&gt; (unstage a file)?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git restore &lt;span class="nt"&gt;--staged&lt;/span&gt; filename.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This doesn't delete your changes, it just removes the file from the staging area. Your edits are still there.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;git revert&lt;/code&gt; — undoing a commit without rewriting history
&lt;/h2&gt;

&lt;p&gt;Made a commit you shouldn't have? The temptation is to use &lt;code&gt;git reset&lt;/code&gt;, but there's a problem: it rewrites history, which can cause a mess for teams.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git revert&lt;/code&gt; is safer: it creates a &lt;strong&gt;new commit&lt;/strong&gt; that undoes the changes from a 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 revert abc1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The history stays intact, you just add a new commit that reverts the damage. Perfect for team environments.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. &lt;code&gt;git cherry-pick&lt;/code&gt; — taking only what you need
&lt;/h2&gt;

&lt;p&gt;Imagine you have a bugfix on a feature branch, but you need to apply that fix to &lt;code&gt;main&lt;/code&gt; right now, without merging everything.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cherry-pick&lt;/code&gt; takes a specific commit and applies it to 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 cherry-pick abc1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch to the target branch, run this command with the hash of the commit you want, and done. Only that commit gets copied over.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bonus: aliases that will save you time
&lt;/h2&gt;

&lt;p&gt;Tired of typing &lt;code&gt;git log --oneline --graph --all&lt;/code&gt; every time? Create an alias:&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; alias.tree &lt;span class="s2"&gt;"log --oneline --graph --all"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You can create aliases for any command. Some I use all the time:&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; alias.st &lt;span class="s2"&gt;"status"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; alias.co &lt;span class="s2"&gt;"checkout"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; alias.unstage &lt;span class="s2"&gt;"restore --staged"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Summary
&lt;/h2&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;When to use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git stash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Save work in progress to switch context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git log --oneline&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;View history in a readable way&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git diff --staged&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Review what's going into the next commit&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;Fix the last commit (message or files)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git restore&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Undo changes in files&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 commit in a team environment&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 a specific commit to another branch&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;These commands aren't advanced — they're &lt;strong&gt;essential&lt;/strong&gt;. They're what separates someone who "uses Git" from someone who actually works well with it.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>terminal</category>
    </item>
  </channel>
</rss>
