Want a GitHub Actions workflow that edits files and commits them back automatically? 🔁 This post shows a minimal, reliable pattern using git CLI inside Actions. It walks through checkout, making changes, detecting diffs, configuring git user/email, and conditionally committing & pushing. Key takeaways: - 🧾 Use actions/checkout@v4 to get repo files. - 🛠️ Make file changes in a run step (any script/action). - 🔍 Detect changes with git diff and set an output (avoid empty commits). - 🧑💻 Configure git user.name/email with ${{ github.actor }}@users.noreply.github.com then git add/commit/push. Read it for a copy‑paste workflow you can drop into your repo. https://lnkd.in/erkvYydE #GitHubActions #Git #CI_CD #DevOps
Automate File Edits with GitHub Actions
More Relevant Posts
-
Want your GitHub Action to edit files and push the results back to the repo? 🔁 You don’t need a custom action — just run git CLI inside a workflow. This post walks through checkout, making changes, detecting diffs, configuring git user/email, and committing + pushing safely. Key takeaways: - Use actions/checkout@v4 to get the repo ⚙️ - Modify files in a run step (scripts/commands) ✍️ - Detect changes with git diff and set an output to avoid failed commits 🔍 - Configure user.name/email with ${{ github.actor }} and @users.noreply.github.com 👤 - Commit (git add ., git commit) and push only when has_changes == 'true' ✅ Why read: includes a full ready-to-use workflow YAML you can drop into your repo. 💡 Read more: https://lnkd.in/erkvYydE #GitHubActions #GitHub #CICD #DevOps
To view or add a comment, sign in
-
*** Git Day 4 *** Complete Guide: Create GitHub Account, Push Code, and Generate Token 📌 1. Introduction to GitHub GitHub is a cloud-based platform used to store, manage, and collaborate on code using Git version control. 📌 2. Create a GitHub Account (Step-by-Step) Step 1: Open Website ◾ Go to: https://github.com Step 2: Sign Up ◾ Click Sign up ◾ Enter: ▪️ Username ▪️ Email address ▪️ Password Step 3: Verify Account ◾ Complete CAPTCHA verification ◾ Verify email using OTP/link Step 4: Account Ready ◾ Choose free plan ◾ Your GitHub dashboard will open 📌 3. Create a Repository in GitHub Steps: 1. Login to GitHub 2. Click + (top right) → New repository 3. Enter: ▪️ Repository name ▪️ Description (optional) 4. Choose: ▪️ Public / Private 5. Click Create repository 📌 4. Integrate Repository (GitHub) to Local Step 1: Initialize Git: git init Step 2: Add all Files: git add . Step 3: Commit Changes: git commit -m "Initial commit" filename Step 4: Connect to GitHub Repo: git remote add origin URL Step 5: To check if git is linked with any repo: git remote -v 📌 5. Push to Github Push Branch: git push origin branchname Push Multiple branches: git push origin branch1 branch2 Push all branches: git push origin --all 📌 6. Generate GitHub Personal Access Token (PAT) GitHub no longer supports password authentication. You must use a token. 🔷 Steps to Create Token: 1. Go to GitHub → Click Profile Icon (top right) 2. Click Settings 3. Navigate to: ▪️ Developer settings ▪️ Personal access tokens ▪️ Click Tokens (classic) or Fine-grained tokens 🔷 Generate Token: ◾ Click Generate new token ◾ Select: ▪️ Repo access ▪️ Workflow (optional) ◾ Set expiration ◾ Click Generate token Important: Copy the token immediately (you cannot see it again) 📌 7. Use Token While Pushing Code When you push code: git push origin branchname Authentication: ▪️ Username → your GitHub username ▪️ Password → Paste your token here 📌 8. Store Token (Optional - Recommended) To avoid entering token again: git config --global credential.helper store Next time, it will save automatically. Conclusion: By following this guide, you can: ▪️ Create a GitHub account ▪️ Push code from local system ▪️ Generate and use access tokens securely Frontlines EduTech (FLM) #upskilling #git
To view or add a comment, sign in
-
Over time, I realized GitHub is not complicated — it’s just about understanding a few core commands and using them consistently. These are the commands I personally use in my daily workflow to manage code efficiently and avoid unnecessary confusion. Git Commands 1. git init >>Turns your normal folder into a Git project so changes can start being tracked from now on. Example: Run git init inside your project folder after creating it. 2. git clone >>Downloads a complete copy of a project from GitHub (or any remote repo) to your system so you can start working. Example: git clone https://lnkd.in/dpXcHxi5 3. git status >>Shows what files are changed, staged, or not tracked so you always know your current working state. Example: Run git status after editing files to check what changed. 4. git add >>Moves your selected changes into the staging area so they are ready to be saved in the next commit. Example: git add index.html or git add . to add all files. 5. git commit >>Saves your staged changes as a snapshot with a message explaining what you did. Example: git commit -m "Added login page UI" 6. git push >>Uploads your committed changes to GitHub so your work is backed up and available to others. Example: git push origin main 7. git pull >>Fetches the latest changes from GitHub and updates your project to stay in sync. Example: git pull origin main 8. git branch >>Creates or manages branches so you can work on features separately without affecting main code. Example: git branch feature-login 9. git checkout >>Switches between branches or lets you create and move to a new branch in one step. Example: git checkout -b feature-dashboard 10. git merge >>Combines changes from one branch into another, usually after completing a feature. Example: git merge feature-login 11. git diff >>Shows exact line-by-line changes between files or commits so you can review before saving. Example: git diff index.html 12. git log >>Displays the history of commits so you can track what changes were made and when. Example: git log --oneline Git is simple: add → commit → push → pull. Everything else is control.
To view or add a comment, sign in
-
Most developers use Git every day and still panic when something breaks. They copy-paste commands from Stack Overflow and hope for the best. I know because I did the same for years. Then I actually looked inside the .git folder. Here's what I found: Git is just a key-value database. It stores 4 types of objects - blobs, trees, commits, and tags. That's the entire system. Once I understood that, every confusing command started making sense. A few things that clicked for me: → A blob stores file content, not the filename, just the raw bytes. Same content = same hash = Git never stores duplicates. → A tree is a directory snapshot. It maps filenames to blob hashes and sub-trees. Your entire project is one tree object pointing to other trees and blobs. → A commit is not a diff. It's a full snapshot of your project at that moment, plus a pointer to the parent commit. That chain of pointers is your history. → A branch is literally a text file with a 40-character hash. That's it. When you commit, Git just updates that file to the new hash. → Detached HEAD isn't scary. It just means HEAD is pointing directly to a commit instead of a branch. Create a branch from there and you're fine. Once you see this, git rebase stops being magic. It's just: save your commits as patches → reset your branch to a new base → re-apply the patches. New hashes, same changes. And merge conflicts stop feeling random. Git is literally asking: "Both of you changed the same lines, which one is right?" I put this all together in a free PDF, 11 pages, dark theme, code examples throughout. Explains Git's internals from objects to branches to merge vs rebase, as simply as I could write it. Download it from this post. Save it for the next time someone on your team panics about a detached HEAD. #Git #SoftwareEngineering 11 pages covering: - Blob, Tree, Commit objects explained simply - Why branches are just text files - HEAD and Detached HEAD demystified - Staging area (the index) - actually explained - How merge and rebase work step-by-step - Common Git mistakes + how to fix them - Full cheat sheet
To view or add a comment, sign in
-
Get the current branch name in GitHub Actions in 10 seconds. 🔎 Two quick ways — shell parameter expansion and a bash command — let you extract the branch from GITHUB_REF and use it in later steps. Store it in GITHUB_ENV and you can tag Docker images, run branch-specific deploys, or gate jobs with github.ref. Takeaways: 1) Use ${GITHUB_REF#refs/heads/} to strip the prefix in-shell. 🧩 2) Or run: $(echo ${GITHUB_REF} | cut -d'/' -f3) for bash parsing. 🪓 3) Persist with: echo "BRANCH_NAME=… " >> $GITHUB_ENV for later steps. 💾 4) Tag/push images: docker build -t myapp:${{ env.BRANCH_NAME }} . && docker push … 🐳 5) Use github.ref in expressions/conditionals (if: ${{ github.ref == 'refs/heads/main' }}). Why read: If you need reliable branch-aware CI/CD (tags, env routing, or conditional jobs), this is the practical guide. Read the full examples and YAML snippets: https://lnkd.in/eeEakbk5 #GitHubActions #GitHub #Docker #bash #GITHUB_REF
To view or add a comment, sign in
-
Before You Read the Code, Read the Git History When I open a new codebase, the first thing I don’t do is open the code. Instead, I open the terminal. This blog by Ally Piechowski made me pause and nod repeatedly—it articulates a practice many experienced engineers intuitively follow, but rarely write down so clearly: Git history tells you where a codebase hurts before you read a single file. The post walks through five simple Git commands that act like a diagnostic scan of a project: 🔍 What changes the most? High‑churn files often come with fear attached—“Everyone’s afraid to touch that file.” It’s not always bad, but when churn combines with bugs, you’ve found real risk. 🧑💻 Who built this? A quick look at contributor distribution reveals the bus factor instantly. If most commits came from one person—especially someone who’s no longer around—that’s not a knowledge gap, it’s a landmine. 🐞 Where do bugs cluster? Filtering commit history for fix|bug|broken exposes files that keep breaking but never truly get fixed. These are the hotspots no architecture diagram will show you. 📉 Is the project accelerating—or dying? Commit velocity over time reflects team health, not just delivery speed. Sudden drops often correlate with attrition or burnout long before leadership notices. 🚨 How often is the team firefighting? Frequent reverts and hotfixes signal deeper systemic issues—tests, CI/CD, or release confidence. Silence can also be a signal… sometimes of poor commit discipline. Why this matters These commands take minutes, yet they help you: Decide what to read first Ask better questions of the team Avoid spending your first week wandering blindly This is how you turn onboarding from guesswork into informed exploration. 📖 Read the full blog here: https://lnkd.in/g3nch4Mh I’m curious— 👉 What’s the first signal you look for when you join or audit a new codebase?
To view or add a comment, sign in
-
Most beginners confuse Git and GitHub. They are NOT the same thing. 🙅 Here's everything you need to know 👇 🔴 𝗚𝗶𝘁 — 𝗩𝗲𝗿𝘀𝗶𝗼𝗻 𝗖𝗼𝗻𝘁𝗿𝗼𝗹 𝗦𝘆𝘀𝘁𝗲𝗺 ∟ Tracks every change in your code ∟ Lives on YOUR computer locally ∟ Allows you to go back to any version ∟ Works completely offline ✅ 🐙 𝗚𝗶𝘁𝗛𝘂𝗯 — 𝗖𝗼𝗱𝗲 𝗛𝗼𝘀𝘁𝗶𝗻𝗴 𝗣𝗹𝗮𝘁𝗳𝗼𝗿𝗺 ∟ Cloud storage for your Git repositories ∟ Enables team collaboration & social coding ∟ Stores your code remotely & safely ☁️ ⚙️ 𝗚𝗶𝘁𝗛𝘂𝗯 𝗔𝗰𝘁𝗶𝗼𝗻𝘀 — 𝗖𝗜/𝗖𝗗 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻 ∟ Automates your entire workflow ∟ Runs tests, builds & deploys automatically ∟ Zero manual deployment needed 🚀 📋 𝗚𝗶𝘁 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 𝗘𝘃𝗲𝗿𝘆 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿 𝗠𝘂𝘀𝘁 𝗞𝗻𝗼𝘄 👇 🟢 𝗦𝗲𝘁𝘂𝗽 & 𝗜𝗻𝗶𝘁𝗶𝗮𝗹𝗶𝘇𝗲 𝙜𝙞𝙩 𝙞𝙣𝙞𝙩 # Start a new repo 𝙜𝙞𝙩 𝙘𝙡𝙤𝙣𝙚 <𝙪𝙧𝙡> # Copy a remote repo 🔵 𝗗𝗮𝗶𝗹𝘆 𝗪𝗼𝗿𝗸𝗳𝗹𝗼𝘄 𝙜𝙞𝙩 𝙨𝙩𝙖𝙩𝙪𝙨 # Check current state 𝙜𝙞𝙩 𝙖𝙙𝙙 <𝙛𝙞𝙡𝙚> # Stage a file 𝙜𝙞𝙩 𝙖𝙙𝙙 . # Stage everything 𝙜𝙞𝙩 𝙘𝙤𝙢𝙢𝙞𝙩 -𝙢 "" # Save with message 🟠 𝗕𝗿𝗮𝗻𝗰𝗵𝗲𝘀 𝙜𝙞𝙩 𝙗𝙧𝙖𝙣𝙘𝙝 # List all branches 𝙜𝙞𝙩 𝙗𝙧𝙖𝙣𝙘𝙝 <𝙣𝙖𝙢𝙚> # Create new branch 𝙜𝙞𝙩 𝙘𝙝𝙚𝙘𝙠𝙤𝙪𝙩 <𝙣𝙖𝙢𝙚> # Switch branch 𝙜𝙞𝙩 𝙘𝙝𝙚𝙘𝙠𝙤𝙪𝙩 -𝙗 # Create + switch 🔴 𝗦𝗲𝗻𝗱 𝗖𝗵𝗮𝗻𝗴𝗲𝘀 𝙜𝙞𝙩 𝙥𝙪𝙨𝙝 𝙤𝙧𝙞𝙜𝙞𝙣 <𝙗𝙧𝙖𝙣𝙘𝙝> # Push to remote 𝙜𝙞𝙩 𝙥𝙪𝙡𝙡 𝙤𝙧𝙞𝙜𝙞𝙣 <𝙗𝙧𝙖𝙣𝙘𝙝> # Fetch + merge 𝙜𝙞𝙩 𝙛𝙚𝙩𝙘𝙝 𝙤𝙧𝙞𝙜𝙞𝙣 # Download only 🟣 𝗨𝗻𝗱𝗼 & 𝗥𝗲𝘀𝗲𝘁 𝙜𝙞𝙩 𝙧𝙚𝙨𝙩𝙤𝙧𝙚 <𝙛𝙞𝙡𝙚> # Discard changes 𝙜𝙞𝙩 𝙧𝙚𝙨𝙚𝙩 --𝙨𝙤𝙛𝙩 # Keep changes 𝙜𝙞𝙩 𝙧𝙚𝙨𝙚𝙩 --𝙝𝙖𝙧𝙙 # Delete changes ⚠️ 🟡 𝗛𝗶𝘀𝘁𝗼𝗿𝘆 & 𝗖𝗼𝗺𝗽𝗮𝗿𝗶𝘀𝗼𝗻 𝙜𝙞𝙩 𝙡𝙤𝙜 # Full commit history 𝙜𝙞𝙩 𝙙𝙞𝙛𝙛 # See all changes 𝙜𝙞𝙩 𝙙𝙞𝙛𝙛 --𝙨𝙩𝙖𝙜𝙚𝙙 # Staged vs last commit 𝙜𝙞𝙩 𝙨𝙝𝙤𝙬 <𝙞𝙙> # Details of a commit ⚫ 𝗦𝘁𝗮𝘀𝗵 (𝗦𝗮𝘃𝗲 𝗪𝗼𝗿𝗸 𝗧𝗲𝗺𝗽𝗼𝗿𝗮𝗿𝗶𝗹𝘆) 𝙜𝙞𝙩 𝙨𝙩𝙖𝙨𝙝 # Save current changes 𝙜𝙞𝙩 𝙨𝙩𝙖𝙨𝙝 𝙡𝙞𝙨𝙩 # View all stashes 𝙜𝙞𝙩 𝙨𝙩𝙖𝙨𝙝 𝙥𝙤𝙥 # Apply & remove stash 🔄 The 4 Steps to Push Code to GitHub 1️⃣ SAVE → Save files in your editor 2️⃣ ADD → git add . (stage changes) 3️⃣ COMMIT → git commit -m "your message" 4️⃣ PUSH → git push origin <branch> That's it. Save → Add → Commit → Push ✅ Git is the tool. GitHub is where you store the work. GitHub Actions is how you automate it. 💪 Every developer needs all three. 🎯 Save this 🔖 — your complete Git cheat sheet is now ready. Follow for daily coding tips & developer resources. 💡 #Git #GitHub #Coding #Programming #WebDevelopment #DevOps #SoftwareEngineering #Tech #LearnToCode #Developer
To view or add a comment, sign in
-
-
My git config grew over years. After a recent round of improvements I decided to write about it :) Five settings that made the biggest difference: rerere.enabled = true — Git records how you resolved a conflict. Same conflict again? Applied automatically. The sleeper hit most people don't know exists. rebase.autoSquash + autoStash + updateRefs — three settings that turn rebase from a ceremony into a one-liner. No manual stashing, automatic fixup folding, and all stacked branches move together. core.fsmonitor + untrackedCache — git status drops from hundreds of milliseconds to near-instant on large repos. A filesystem watcher replaces full directory scans. merge.conflictstyle = zdiff3 — conflict markers show three versions: yours, theirs, and the original. Once you see the common ancestor, the default style feels blind. push.autoSetupRemote + followTags — first push on a new branch, just git push. Tags travel with the code. No more -u origin branch-name, no more forgotten --tags. Full config with the story behind each section: https://lnkd.in/gymnYVQi Inspired by https://lnkd.in/g4KnmrQ9 #Git #CLI #DevTools #DeveloperProductivity
To view or add a comment, sign in
-
🚀 Why We Actually Moved to GitHub Actions (From Jenkins) Recently in one of the discussions, someone asked me: Why shift to GitHub Actions when Jenkins is already working fine? Honestly… I used to think the same. Jenkins has been around forever and it works. But once your environment starts growing, things slowly become painful. What We Started Facing with Jenkins In smaller setups, Jenkins is great. But at scale, the story changes. We started seeing: • too many plugins to manage • frequent plugin conflicts after upgrades • maintaining Jenkins infra became a separate effort • scaling agents was not always smooth • handling credentials securely needed extra effort At one point, we realized: we were spending more time managing Jenkins than actually building pipelines Why GitHub Actions Made More Sense When we started exploring GitHub Actions, the biggest difference was simple: CI/CD lives with your code No separate tool, no extra server. Everything is: • repo-based • event-driven (PR, push, release) • YAML defined • auto-scaled It just felt more… natural. What Improved After Moving Not saying Jenkins is bad — but for our use case, GitHub Actions simplified a lot. Here’s what actually improved for us: ✔ No infra to manage ✔ Pipelines version-controlled with code ✔ Faster onboarding for developers ✔ Scaling handled automatically ✔ Better integration with PR workflows Developers didn’t have to “learn Jenkins” anymore. They just worked inside GitHub. How We Made the Pipeline Secure This is where things really matter. Moving tools doesn’t improve security automatically — you have to design it properly. Here’s what we focused on: Identity & Access First thing we fixed: • stopped using long-lived credentials • moved to OIDC-based authentication • enforced least privilege everywhere No more storing cloud keys in pipelines. Security Checks in Pipeline We added checks directly into workflows: • code scanning • dependency checks • container scanning (Trivy) • secret detection So issues are caught early, not after deployment. Artifact Trust Before pushing images: • scan everything • sign artifacts using Cosign • allow only trusted images Pre-Deployment Checks Before anything goes to prod: • run security tests (ZAP) • enforce policies • block risky deployments Runtime Monitoring Even after deployment: • monitor behavior • detect anomalies • alert on suspicious activity Security doesn’t stop at CI/CD. Final Thought For me, the biggest shift was this: 👉 Jenkins = managing pipelines 👉 GitHub Actions = pipelines become part of development #GitHubActions #DevOps #CI_CD #CloudSecurity #DevSecOps #PlatformEngineering
To view or add a comment, sign in
-
-
🗓️ Day 31/100 — 100 Days of AWS & DevOps Challenge Phase 3 opens with git stash — one of the most practical and underappreciated Git tools in daily engineering work. The task: A developer stashed some in-progress changes. Restore specifically stash@{1}, commit it, and push. $ git stash list # stash@{0}: WIP on master: abc1234 latest work # stash@{1}: WIP on master: def5678 earlier work ← target $ git stash show stash@{1} # preview before applying $ git stash apply stash@{1} # restore to working tree $ git add . $ git commit -m "Restore stash@{1} changes" $ git push origin master The real-world scenario this maps to: You're deep into a feature files changed, half the logic written, nothing committed. A Slack message arrives: production is down, hotfix needed now. You can't commit half-baked code to master. You can't just leave the changes and switch branches — Git may refuse or mix things up. $ git stash # shelve everything, get a clean tree $ git checkout master # fix the issue, commit, deploy $ git checkout feature/my-work $ git stash pop # pick up exactly where you left off Zero lost work. Clean context switch. That's what stash is for. apply vs pop — when it matters: git stash pop restores and removes the stash. git stash apply restores and keeps it. For stash@{1} specifically — not the most recent stash — apply is the safer choice. The stash stays in the list as a backup while you verify the applied changes look right before committing. You can git stash drop stash@{1} afterward if you want it gone. One more thing: always git stash show stash@{1} before applying. It shows exactly which files were modified. Applying blind to a dirty working tree risks silent conflicts that are harder to untangle later. Full stash guide on GitHub 👇 https://lnkd.in/gpdZFruW #DevOps #Git #VersionControl #GitOps #Linux #100DaysOfDevOps #KodeKloud #LearningInPublic #CloudEngineering #SRE #Infrastructure
To view or add a comment, sign in
More from this author
-
Level up your career with the comprehensive HashiCorp Terraform course from Build5Nines!
Build5Nines LLC 1y -
Azure AI Fundamentals and AI-Ready Infrastructure Courses Released to Build5Nines Membership
Build5Nines LLC 1y -
Are you looking to advance your career and need guidance on your Microsoft certification journey?
Build5Nines LLC 1y
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