Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 14, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 14, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 14, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 14, 2025

      I test a lot of AI coding tools, and this stunning new OpenAI release just saved me days of work

      May 14, 2025

      How to use your Android phone as a webcam when your laptop’s default won’t cut it

      May 14, 2025

      The 5 most customizable Linux desktop environments – when you want it your way

      May 14, 2025

      Gen AI use at work saps our motivation even as it boosts productivity, new research shows

      May 14, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025
      Recent

      Strategic Cloud Partner: Key to Business Success, Not Just Tech

      May 14, 2025

      Perficient’s “What If? So What?” Podcast Wins Gold at the 2025 Hermes Creative Awards

      May 14, 2025

      PIM for Azure Resources

      May 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025
      Recent

      Windows 11 24H2’s Settings now bundles FAQs section to tell you more about your system

      May 14, 2025

      You can now share an app/browser window with Copilot Vision to help you with different tasks

      May 14, 2025

      Microsoft will gradually retire SharePoint Alerts over the next two years

      May 14, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Helpful Git Aliases To Maximize Developer Productivity

    Helpful Git Aliases To Maximize Developer Productivity

    May 14, 2025
    Git is a powerful tool, but it can sometimes be overwhelming with the number of commands required to perform common tasks. If you’ve ever found yourself typing out long, complex Git commands and wondered if there’s a faster way to get things done, you’re not alone. One way to streamline your workflow and reduce repetitive typing is by using Git aliases. These are shorthand commands that allow you to perform lengthy Git operations with just a few characters.
     
    In this post, we’ll explore some useful Git aliases that can help you maximize your productivity, speed up common workflows, and maintain a clean Git history.

    How To Add Aliases To Your Git Config File

    To start using Git aliases, you need to add them to your .gitconfig file. This file is typically located in your home directory, and it contains various configurations for your Git setup, including user details and aliases.
     
    Here’s how to add aliases:
      1. Open the .gitconfig file:
        • On Linux/MacOS, the .gitconfig file is typically located in your home directory (~/.gitconfig).
        • On Windows, it is located at C:Users<YourUsername>.gitconfig.
      2. Edit the .gitconfig file: You can manually add aliases to the [alias] section. If this section doesn’t already exist, simply add it at the top or bottom of the file. Below is an example of how your .gitconfig file should look once you add the aliases that we will cover in this post:
        [alias]
          # --- Branching ---
          co = checkout
          cob = checkout -b
          br = branch
        
          # --- Working Directory Status ---
          st = status
          df = diff
        
          # --- Commit & Push ---
          amod = "!f() { git add -u && git commit -m "$1" && git push; }; f"
          acp = "!f() { git add -A && git commit -m "$1" && git push; }; f"
        
          # --- Stash ---
          ss = stash
          ssd = stash drop
        
          # --- Reset / Cleanup ---
          nuke = reset --hard
          resetremote = !git reset --hard origin/main
        
          # --- Rebase Helpers ---
          rbc = rebase --continue
          rba = rebase --abort
          rbi = rebase -i
        
          # --- Log / History ---
          hist = log --oneline --graph --decorate --all
          ln = log --name-status
        
          # --- Fetch & Sync ---
          fetch = fetch --all --prune
          pullr = pull --rebase
          up = !git fetch --prune && git rebase origin/$(git rev-parse --abbrev-ref HEAD)
          cp = cherry-pick
      3. Save and close the file: Once you’ve added your aliases, save the file, and your new aliases will be available the next time you run Git commands in your terminal.
      4. Test the aliases: After saving your .gitconfig file, you can use your new aliases immediately. For example, try using git co to switch branches or git amod "your commit message" to commit your changes.

    Explanation of the Aliases

    I find these to be very helpful in my day-to-day work as a web developer. Here are some explanations of the aliases that I have added:

    Branching

    co = checkout

    When switching between branches, this alias saves you from typing git checkout <branch_name>. With co, switching is as simple as:
    git co <branch_name>
     

    cob = checkout -b

    Creating and switching to a new branch is easier with this alias. Instead of git checkout -b <new_branch_name>, simply use: 
    git cob <new_branch_name>
     

    br = branch

    If you need to quickly list all branches, whether local or remote, this alias is a fast way to do so:
    git br
     

    Working Directory Status

    st = status

    One of the most frequently used commands in Git, git status shows the current state of your working directory. By aliasing it as st, you save time while checking what’s been staged or modified:
    git st
     

    df = diff

    If you want to view the changes you’ve made compared to the last commit, use df for a quick comparison:
    git df
     

    Commit and Push

    amod = “!f() { git add -u && git commit -m ”$1” && git push; }; f”

    For quick commits, this alias allows you to add modified and deleted files (but not new untracked files), commit, and push all in one command! It’s perfect for when you want to keep things simple and focus on committing changes:
    git amod "Your commit message"
     

    acp = “!f() { git add -A && git commit -m ”$1” && git push; }; f”

    Similar to amod, but this version adds all changes, including untracked files, commits them, and pushes to the remote. It’s ideal when you’re working with a full set of changes:
    git acp "Your commit message"
     

    Stash

    ss = stash

    When you’re in the middle of something but need to quickly save your uncommitted changes to come back to later, git stash comes to the rescue. With this alias, you can stash your changes with ease:
    git ss
     

    ssd = stash drop

    Sometimes, after stashing, you may want to drop the stashed changes. With ssd, you can easily discard a stash:
    git ssd
     

    Reset / Cleanup

    nuke = reset –hard

    This alias will discard all local changes and reset your working directory to the last commit. It’s especially helpful when you want to start fresh or undo your recent changes:
    git nuke
     

    resetremote = !git reset –hard origin/main

    When your local branch has diverged from the remote and you want to match it exactly, this alias will discard local changes and reset to the remote branch. It’s a lifesaver when you need to restore your local branch to match the remote:
    git resetremote
     

    Rebase Helpers

    rbc = rebase –continue

    If you’re in the middle of a rebase and have resolved any conflicts, git rebase --continue lets you proceed. The rbc alias lets you continue the rebase without typing the full command: 
    git rbc
     

    rba = rebase –abort

    If something goes wrong during a rebase and you want to abandon the process, git rebase --abort will undo all changes from the rebase. This alias makes it quick and easy to abort a rebase:
    git rba
     

    rbi = rebase -i

    For an interactive rebase, where you can squash or reorder commits, git rebase -i is an essential command. The rbi alias will save you from typing the whole command:
    git rbi
     

    Log / History

    hist = log –oneline –graph –decorate –all

    For a good-looking, concise view of your commit history, this alias combines the best of git log. It shows commits in a graph format, with decoration to show branch names and tags, all while keeping the output short:
    git hist
     

    ln = log –name-status

    When you need to see what files were changed in each commit (with their status: added, modified, deleted), git log --name-status is invaluable. The ln alias helps you inspect commit changes more easily:
    git ln
     

    Fetch and Sync

    fetch = fetch –all –prune

    Fetching updates from all remotes and cleaning up any deleted branches with git fetch --all --prune is essential for keeping your remotes organized. The fetch alias makes this task a single command:
    git fetch
     

    pullr = pull –rebase

    When removing changes from the remote, rebase are often better than merges. This keeps your history linear and avoids unnecessary merge commits. The pullr alias performs a pull with a rebase:
    git pullr

    up = !git fetch –prune && git rebase origin/$(git rev-parse –abbrev-ref HEAD)

    This alias is a great shortcut if you want to quickly rebase your current branch onto its remote counterpart. It first fetches the latest updates from the remote and prunes any deleted remote-tracking branches, ensuring your local references are clean and up to date. Then it rebases your branch onto the corresponding remote, keeping your history in sync:
    git up
     

    cp = cherry-pick

    Cherry-picking allows you to apply a specific commit from another branch to your current branch. This alias makes it easier to run:
    git cp <commit-hash>

    Final Thoughts

    By setting up these Git aliases, you can reduce repetitive typing, speed up your development process, and make your Git usage more efficient. Once you’ve incorporated a few into your routine, they become second nature. Don’t hesitate to experiment and add your own based on the commands you use most. Put these in your .gitconfig file today and start enjoying the benefits of a more productive workflow!

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleUnlock Automation Success: Power Automate Workshops at TechCon365 PWRCON
    Next Article 5 Questions to ask CCaaS Vendors as you Plan Your Cloud Migration

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 15, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-4695 – PHPGurukul Cyber Cafe Management System SQL Injection

    May 15, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Human-AI Collaboration in Physical Tasks

    Development

    CVE-2025-42601 – Meon KYC Captcha Bypass Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    I can’t review a game if I can’t finish it, and Still Wakes the Deep is broken because of this bug

    Development

    CVE-2025-46580 – GoldenDB Database Information Disclosure and Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Microsoft Patches Four Critical Azure and Power Apps Vulnerabilities, Including CVSS 10 Privilege Escalation

    May 9, 2025

    Microsoft Patches Four Critical Azure and Power Apps Vulnerabilities, Including CVSS 10 Privilege Escalation

    Microsoft has addressed a cluster of critical vulnerabilities affecting several of its core cloud services—including Azure Automation, Azure Storage, Azure DevOps, and Microsoft Power Apps. Although n …
    Read more

    Published Date:
    May 09, 2025 (5 hours, 12 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-47733

    CVE-2025-29972

    CVE-2025-29827

    CVE-2025-29813

    CVE-2025-21298

    Microsoft Excel now lets users translate and detect the language of their texts

    June 28, 2024

    CVE-2025-32011 – KUNBUS PiCtory Authentication Bypass Vulnerability

    May 1, 2025

    Figma Sites Isn’t the Future

    May 14, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.