𝗚𝗶𝘁 - 𝗧𝗵𝗲 𝗱𝗮𝗶𝗹𝘆 𝗧𝗶𝗽 As we all know git is one the most powerful tool we have, here are some tips to "optimize" your daily work 𝙗𝙧𝙖𝙣𝙘𝙝.𝙨𝙤𝙧𝙩 -𝙘𝙤𝙢𝙢𝙞𝙩𝙩𝙚𝙧𝙙𝙖𝙩𝙚 What 𝚋𝚛𝚊𝚗𝚌𝚑.𝚜𝚘𝚛𝚝 -𝚌𝚘𝚖𝚖𝚒𝚝𝚝𝚎𝚛𝚍𝚊𝚝𝚎 Does When you set this configuration, any command that lists branches (like 𝚐𝚒𝚝 𝚋𝚛𝚊𝚗𝚌𝚑) will sort them based on the 𝗱𝗮𝘁𝗲 𝗼𝗳 𝘁𝗵𝗲 𝗹𝗮𝘀𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 made to that branch. 𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱 𝗯𝗲𝗵𝗮𝘃𝗶𝗼𝗿: • Branches are listed A-Z. 𝗪𝗶𝘁𝗵 𝘁𝗵𝗶𝘀 𝘀𝗲𝘁𝘁𝗶𝗻𝗴: • The branches with the most recent activity appear at the bottom of the list (closest to your prompt), making them much easier to find in a repository with dozens of stale branches. 𝗣𝗿𝗼-𝗧𝗶𝗽: Adding More Detail • If you want an even more powerful view of your recent work, you can create a "𝘀𝘂𝗽𝗲𝗿 𝗮𝗹𝗶𝗮𝘀" that shows the date and the last commit message: • Set alias 𝙜𝙞𝙩 𝙘𝙤𝙣𝙛𝙞𝙜 --𝙜𝙡𝙤𝙗𝙖𝙡 𝙖𝙡𝙞𝙖𝙨.𝙧𝙡 "𝙗𝙧𝙖𝙣𝙘𝙝 --𝙨𝙤𝙧𝙩=-𝙘𝙤𝙢𝙢𝙞𝙩𝙩𝙚𝙧𝙙𝙖𝙩𝙚 --𝙛𝙤𝙧𝙢𝙖𝙩='%(𝙖𝙪𝙩𝙝𝙤𝙧𝙙𝙖𝙩𝙚:𝙧𝙚𝙡𝙖𝙩𝙞𝙫𝙚)%𝟬𝟵%(𝙧𝙚𝙛𝙣𝙖𝙢𝙚:𝙨𝙝𝙤𝙧𝙩)%𝟬𝟵%(𝙨𝙪𝙗𝙟𝙚𝙘𝙩)'" You just created a powerful new Git alias named 𝚛𝚕 (Recent List). 𝗨𝘀𝗮𝗴𝗲: 𝗴𝗶𝘁 𝗿𝗹 Enjoy.... #GIt #DevOps
Optimize Your Daily Git Work with Branch Sorting
More Relevant Posts
-
This is a very useful tip. Especially when working in a team with many branches and many commits. You can set it up to immediately see what branch was most recently used, when was the most recent commit, what was it, and maybe even add the person who committed.
𝗚𝗶𝘁 - 𝗧𝗵𝗲 𝗱𝗮𝗶𝗹𝘆 𝗧𝗶𝗽 As we all know git is one the most powerful tool we have, here are some tips to "optimize" your daily work 𝙗𝙧𝙖𝙣𝙘𝙝.𝙨𝙤𝙧𝙩 -𝙘𝙤𝙢𝙢𝙞𝙩𝙩𝙚𝙧𝙙𝙖𝙩𝙚 What 𝚋𝚛𝚊𝚗𝚌𝚑.𝚜𝚘𝚛𝚝 -𝚌𝚘𝚖𝚖𝚒𝚝𝚝𝚎𝚛𝚍𝚊𝚝𝚎 Does When you set this configuration, any command that lists branches (like 𝚐𝚒𝚝 𝚋𝚛𝚊𝚗𝚌𝚑) will sort them based on the 𝗱𝗮𝘁𝗲 𝗼𝗳 𝘁𝗵𝗲 𝗹𝗮𝘀𝘁 𝗰𝗼𝗺𝗺𝗶𝘁 made to that branch. 𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱 𝗯𝗲𝗵𝗮𝘃𝗶𝗼𝗿: • Branches are listed A-Z. 𝗪𝗶𝘁𝗵 𝘁𝗵𝗶𝘀 𝘀𝗲𝘁𝘁𝗶𝗻𝗴: • The branches with the most recent activity appear at the bottom of the list (closest to your prompt), making them much easier to find in a repository with dozens of stale branches. 𝗣𝗿𝗼-𝗧𝗶𝗽: Adding More Detail • If you want an even more powerful view of your recent work, you can create a "𝘀𝘂𝗽𝗲𝗿 𝗮𝗹𝗶𝗮𝘀" that shows the date and the last commit message: • Set alias 𝙜𝙞𝙩 𝙘𝙤𝙣𝙛𝙞𝙜 --𝙜𝙡𝙤𝙗𝙖𝙡 𝙖𝙡𝙞𝙖𝙨.𝙧𝙡 "𝙗𝙧𝙖𝙣𝙘𝙝 --𝙨𝙤𝙧𝙩=-𝙘𝙤𝙢𝙢𝙞𝙩𝙩𝙚𝙧𝙙𝙖𝙩𝙚 --𝙛𝙤𝙧𝙢𝙖𝙩='%(𝙖𝙪𝙩𝙝𝙤𝙧𝙙𝙖𝙩𝙚:𝙧𝙚𝙡𝙖𝙩𝙞𝙫𝙚)%𝟬𝟵%(𝙧𝙚𝙛𝙣𝙖𝙢𝙚:𝙨𝙝𝙤𝙧𝙩)%𝟬𝟵%(𝙨𝙪𝙗𝙟𝙚𝙘𝙩)'" You just created a powerful new Git alias named 𝚛𝚕 (Recent List). 𝗨𝘀𝗮𝗴𝗲: 𝗴𝗶𝘁 𝗿𝗹 Enjoy.... #GIt #DevOps
To view or add a comment, sign in
-
-
Wrote a short note on something I recently found useful while working with Git — git cherry-pick. It helped me move specific commits across branches without merging everything, especially in a GitFlow setup. Tried to keep it simple and practical. Read here: https://lnkd.in/dt4xQ7Da #git #devops #versioncontrol
To view or add a comment, sign in
-
Git by itself will happily let you commit: ▪️ Ugly formatting ▪️ Failing code ▪️ Secrets ▪️ Broken configs It doesn't assess quality; it just stores snapshots, which is why automation is vital within teams to catch problems early. There are 3 Key Layers: 1️⃣ .gitignore Your first line of defence, it prevents you from tracking sensitive information by telling Git what not to track: ▪️.env files (secrets) ▪️Dependencies ▪️Logs ▪️System Files If set up properly, a lot of problems can be prevented. 2️⃣ Pre-commit hooks A hook is a script that git will run automatically at select points in the git workflow. One of the points is before a commit is created... If it passes these checks, the commit will go through If it fails, the commit will be blocked These checks include: ▪️Linters (code quality) ▪️Tests (does it still work?) ▪️Secret scanning This layer stops bad code before it enters your repo history. But its not perfect and must not be solely relied on. 3️⃣ CI - Continuous Integration This set of checks runs after you push your code CI will: ▪️Run tests ▪️Check formatting ▪️Scan for secrets ▪️Build the project If something fails, your PR will be blocked. The issue here is that it runs after the commit already exists, so the secret is already in history, but the PR won't be merged; warnings will show, and the team will be notified. All 3 are needed to ensure that rules are consistent, checks are automatic, and fewer mistakes reach PRs or the main. If all is well, then the PR will be approved. A Pull Request isn't just a click merge button... It acts as a checkpoint: ▪️Reviews the code ▪️Catches mistakes ▪️Enforces standards A proper workflow: ( *simplified) *Feature Branch ➡️ PR ➡️ Review ➡️ Merge Git doesn't protect you - these layers and check do. #Git #CoderCo #DevOps
To view or add a comment, sign in
-
-
Git Merge vs Git Rebase — do you know when to use each? 🔀 Both commands integrate changes from one branch into another, but they produce very different histories. Git Merge creates a merge commit that ties two branches together while preserving every commit exactly as it happened. It's safe for shared branches and gives you a complete picture of your project history. Git Rebase replays your branch's commits on top of another, rewriting history to produce a clean, linear line. Think of it as saying "pretend I always branched from this point." When to merge: ✅ Integrating a feature branch into main/master ✅ Working on a shared branch with teammates ✅ You want full history preserved When to rebase: ✅ Updating a feature branch with the latest changes before merging ✅ Cleaning up a messy local commit history ✅ You want a readable, linear project history ⚠️ One golden rule: never rebase a branch other developers are actively working on — it rewrites commit hashes and will break their local copies. We've written a full visual walkthrough with step-by-step screenshots using LithiumGit — showing exactly what happens to your commit graph in each scenario. 🔗 Read the full guide: https://lnkd.in/gdvYueJ5
To view or add a comment, sign in
-
🚀 Day 02/100 – Git Configuration, Amend & .gitignore Today I focused on key Git operations related to commit management and repository handling. 🔹 What I revised today: • Git configuration to set username and email for commits • Using git commit --amend to modify the latest commit (message, author, or changes) • Understanding the purpose of .gitignore to avoid tracking unwanted files 🔹 Hands-on I practiced: • git config user.name / user.email • git commit --amend -m "message" • git commit --amend --no-edit • Creating and using .gitignore file 💡 Key Takeaway: Proper configuration and controlling what gets committed helps in maintaining clean and meaningful version history. ⚡ Insight: Using .gitignore effectively prevents unnecessary files from being tracked and keeps the repository organized. Day 2 ✅ #DevOps #Git #100DaysOfDevOps #LearningInPublic
To view or add a comment, sign in
-
Git Series | Day 8: Mastering Git Rebase — The Professional Standard for Clean History 🛠️✨ Integration is easy; maintaining a clean, readable history is hard. Today I moved beyond the standard 3-way merge to master Git Rebase, the tool that allows DevOps teams to keep their project timelines linear and manageable. 1. The Problem: The "Mixed" History of 3-Way Merges While a 3-way merge works, it has two major drawbacks in large-scale projects: Extra Commits: Every merge creates a "Merge Commit" which doesn't contain actual code changes, just integration data. Non-Linearity: The commit history becomes a "tangled web" of branches crossing over each other, making it difficult to audit or debug specific features. 2. The Solution: What is Rebase? Rebase is the process of moving or combining a sequence of commits to a new base commit. Instead of "merging" the branches, I am effectively rewriting the history so it looks like the feature branch was started from the most recent commit on the master branch. The Result: A perfectly linear history with no extra merge commits. The Command: While on the feature branch, run < git rebase master > 3. The Rebase Conflict Workflow Conflicts in rebase happen commit-by-commit, giving you granular control. My standardized resolution process is now: Identify: Find the file causing the conflict. Resolve: Edit the file, remove the headers/conflict markers. Stage: git add <file>. Safety Valve: If things go wrong, git rebase --abort brings me back to the pre-rebase state. #Git #DevOps #GitRebase #CleanCode #VersionControl #SoftwareArchitecture #100DaysOfCode #GitWorkflow #EngineeringExcellence
To view or add a comment, sign in
-
Most people use Git. Very few understand why it’s so efficient. Here’s the short explanation 👇 🧠 Git = content-based system It doesn’t store files. It stores snapshots (via hashes) Same content? → Stored once. No duplication.(deduplication) ⚙️ What happens in a commit? git commit -m "update" Behind the scenes: • Blob → file content • Tree → folder structure • Commit → snapshot + metadata Everything linked with hashes 🔗 📦 Why Git stays fast • Packfiles → bundle objects • Delta compression → store only changes Change 1 line? Git stores just that. Not the whole file. !! Without this the repose just explode !! 🔧 Hidden layer (most ignore) • Porcelain → git add, git push • Plumbing → actual engine Try this once 👇 echo "hello" | git hash-object -w --stdin You just created a Git object manually. If you understand internals → branching, rebasing, debugging becomes easy. 💡 Insight Git isn’t storing history… It’s storing connected snapshots 📚 Quick refs: https://lnkd.in/gSeM2kmA https://lnkd.in/gEMefujR Git becomes powerful the moment you stop memorizing… and start understanding ⚡ 👉 What part of Git still feels confusing to you? #Git #DevOps #Engineering #Backend — Abhishek Singh Chauhan
To view or add a comment, sign in
-
-
If you’re not familiar with these essential Git commands, you might be missing out on efficiency Here are some must-know Git commands every developer should keep handy: ━━━━━━━━━━━━━━━━━━━━━━ → git init — Initialize a new repository → git clone — Download a repository from remote → git status — Check current changes & status → git add — Add specific file to staging → git add . — Add all files to staging → git commit -m "message" — Save changes with message → git log — View commit history → git log --oneline — Short commit history → git diff — Show changes between commits → git branch — List all branches → git branch — Create new branch → git checkout — Switch branch → git checkout -b — Create & switch branch → git merge — Merge branches → git pull — Fetch & merge latest changes → git push — Upload changes to remote → git stash — Save changes temporarily → git stash pop — Reapply saved changes ━━━━━━━━━━━━━━━━━━━━━━ Mastering these commands can seriously boost your productivity and workflow. Which Git command do you use the most? #Git #Developers #Coding #Programming #Tech #SoftwareDevelopment #LearnToCode #DeveloperLife #CodingTips #CareerGrowth #TechSkills #OpenSource #GitHub #Learning #Productivity
To view or add a comment, sign in
-
-
Demystifying Git: The 4 Core Layers of Git. Most developers treat Git like a magic undo button, but understanding its actual internal architecture completely changes how you use it.These are the 4 core layers of git. • Persistence: Git is a key-value store. Every file (blob), directory (tree), Annotated Tag and commit is saved as an immutable object in .git/objects identified by a unique SHA-1 hash. • Content Tracker: Git tracks complete snapshots of your content, not file differences. These snapshots are maintained by a Tree object, which is dynamically generated from the index file (staging area) at the moment of commit. • Version Control: Git connects your snapshots into a timeline structured as a Directed Acyclic Graph (DAG). The Commit object acts as a node in this graph, storing metadata to link a specific snapshot to its parent history. • Distributed Version Control: Git is peer-to-peer. Every local clone is a fully autonomous backup of the entire project, and network operations (push/fetch) merely sync missing objects and update pointers. Branches, Head and tags aren't duplicated folders; they are like simply lightweight pointers to a commit within the DAG, making branching an instantaneous pointer swap. These insights are heavily inspired by the teachings of Mohit Dharmadhikari at VoidInfinity Tech. #Git #SoftwareEngineering #SystemArchitecture #DistributedVersionControl
To view or add a comment, sign in
-
-
Ever had your git push rejected with a confusing message like: “rejected (fetch first)” “branches have diverged” I recently ran into this — and finally understood what Git was trying to protect me from. Here’s the simple breakdown What’s actually happening? You and the remote repository (GitHub) both made changes. Git blocks your push to prevent overwriting someone else’s work. The fix (clean & safe way): git pull origin main --rebase git push origin main What --rebase really does: Instead of merging, it: Temporarily removes your commits Pulls the latest changes Re-applies your commits on top Result: clean, linear history (no messy merge commits) Common blockers & how to handle them Unstaged changes? You modified files but didn’t stage them yet. Fix: git add -A git commit -m "your message" Not ready to commit? Use stash: git stash git pull --rebase git stash pop Conflicts during rebase? # fix files git add . git rebase --continue Key takeaway If your push is rejected: Always sync first, then push git pull --rebase git push #Git #DevOps #Terraform #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Noice 🙂