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
Edit GitHub Repo Files with Git CLI in Workflow
More Relevant Posts
-
🚨 𝗦𝘁𝗿𝘂𝗴𝗴𝗹𝗶𝗻𝗴 𝘄𝗶𝘁𝗵 𝗚𝗶𝘁𝗟𝗮𝗯 𝗿𝗲𝗽𝗼𝘀𝗶𝘁𝗼𝗿𝘆 𝘀𝗶𝘇𝗲 𝗹𝗶𝗺𝗶𝘁𝘀 𝗱𝘂𝗿𝗶𝗻𝗴 𝗺𝗶𝗿𝗿𝗼𝗿𝗶𝗻𝗴? I recently ran into a 2.9 GB repository issue while setting up GitLab → GitHub mirroring — and the GitLab UI simply couldn’t handle it. Instead of giving up, I took a manual approach using Git + BFG Repo-Cleaner, and it worked flawlessly. ✅ 🔍 𝗪𝗵𝗮𝘁 𝗜 𝗰𝗼𝘃𝗲𝗿𝗲𝗱 𝗶𝗻 𝘁𝗵𝗶𝘀 𝗯𝗹𝗼𝗴: • Why large repositories break mirroring pipelines • How to identify large files hidden in Git history • Step-by-step cleanup using BFG Repo-Cleaner • Essential (often missed) Git commands 🧠 • Optimizing repos with `git gc` & `repack` • Successful mirroring using `--mirror` over SSH 🔐 • Verifying actual size reduction 📉 💡 If you're working with 𝗺𝗼𝗻𝗼𝗿𝗲𝗽𝗼𝘀, 𝗹𝗲𝗴𝗮𝗰𝘆 𝗯𝗶𝗻𝗮𝗿𝗶𝗲𝘀, 𝗼𝗿 𝗹𝗮𝗿𝗴𝗲 𝗚𝗶𝘁 𝗵𝗶𝘀𝘁𝗼𝗿𝘆, this guide will save you hours of debugging. 📖 𝗥𝗲𝗮𝗱 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝗴𝘂𝗶𝗱𝗲 𝗵𝗲𝗿𝗲: https://lnkd.in/gYYs6sfy 🛠️ Key takeaway: - Git problems at scale are rarely about code — they're about history. #Git #GitHub #GitLab #DevOps #SoftwareEngineering #Mirroring #BFG #VersionControl #TechBlog #Developers
Fixing Large Repository GitHub Mirroring Failures Using BFG Repo-Cleaner (GitLab↔ GitHub) medium.com 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
-
I stopped fearing Git the day I learned these 20 commands.....😎 . . Most of us learn `git init`, `git add .`, and `git push` but GitHub is so much more than that. Here’s a quick breakdown I’ve covered in the PDF I’m sharing today: `git init` - Start a new repo `git add .` - Stage all files `git commit -m "message"` - Save the snapshot `git push origin main` - Push to GitHub `git pull origin main` - Get latest changes `git checkout -b branch-name` - Create & switch to a new branch `git log` - View history `git reset --hard` - Rollback changes `git stash` - Save work temporarily `git clean -fd` - Delete untracked files & dirs `git cherry-pick` - Pick specific commits `git rebase` vs `git merge` - When to use what This PDF is your mini GitHub survival kit Don't forget to follow Asif Ali Quraishi ♞ for more 🔥 Comment "Github" and I’ll DM you the PDF Join the group for more hiring updates : https://lnkd.in/gkrqgy_s Tag a dev friend who still says “GitHub scary hai” 😅 #GitHub #GitCommands #CheatSheet #Git
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
-
I stopped fearing Git the day I learned these 20 commands.....😎 . . Most of us learn `git init`, `git add .`, and `git push` but GitHub is so much more than that. Here’s a quick breakdown I’ve covered in the PDF I’m sharing today: `git init` - Start a new repo `git add .` - Stage all files `git commit -m "message"` - Save the snapshot `git push origin main` - Push to GitHub `git pull origin main` - Get latest changes `git checkout -b branch-name` - Create & switch to a new branch `git log` - View history `git reset --hard` - Rollback changes `git stash` - Save work temporarily `git clean -fd` - Delete untracked files & dirs `git cherry-pick` - Pick specific commits `git rebase` vs `git merge` - When to use what This PDF is your mini GitHub survival kit Don't forget to follow Swadesh Kumar for more 🔥 Comment "Github" and I’ll DM you the PDF Join the group for more hiring updates : https://lnkd.in/gkrqgy_s Tag a dev friend who still says “GitHub scary hai” 😅 #GitHub #GitCommands #CheatSheet #Git
To view or add a comment, sign in
-
One of the biggest workflow mistakes I made early in my career was skipping Git and relying on file names, date folders, and server backups. It worked—until it didn’t. Git & GitHub gave me a better way to track changes, recover old work, and collaborate with confidence. For teams, that means fewer mistakes, better accountability, and safer delivery. 💡 #Git #GitHub #VersionControl #DevOps #SoftwareEngineering #TeamCollaboration #TechLeadership https://lnkd.in/dM-MTeQD
To view or add a comment, sign in
-
Back in November I looked at a problem and thought "that's going to be fun to solve." GitHub Copilot CLI running inside a Docker sandbox needs Docker access. Testcontainers, integration tests, build pipelines. They all need a working Docker socket. The obvious answer? Mount /var/run/docker.sock into the container. The obvious answer is also terrifying. That socket is root access to your host machine. Any image, privileged containers, host filesystem mounts. For a human dev, you trust yourself. For Copilot running autonomously... not so much. Last year I built an Airlock feature that hardens network traffic, routing everything through an allowlist-enforcing proxy. That was step one. The Docker socket broker was the piece I kept putting off because the problem was harder. The broker sits between the container and the real Docker daemon. Every API call goes through it. 65 endpoints explicitly allowed, everything else blocked. When Copilot tries to create a container, the broker inspects the body: checks the image against an allowlist (empty by default, you name what you trust), blocks privileged mode, blocks host namespace sharing, blocks mounts to /etc, /root, /var, and the socket itself. Combine it with the Airlock I built last year and sibling containers spawned by Copilot get auto-joined to the isolated network too. Network-level and API-level lockdown at the same time. It wasn't one of those "throw a single prompt at it and it's solved" problems. In standard mode, everything works: Testcontainers, docker builds, multi-service setups. Through Airlock, some scenarios like Testcontainers port connectivity still need work. The feature I built first is ironically the part holding up the last 10%. copilot_here is growing in ways I didn't expect for a tool I built because I was too paranoid to give GitHub Copilot full shell access. 6 external contributors. 81 stars on GitHub. 24.9k container image downloads in the last 30 days (according to GitHub Packages stats). If you're running GitHub Copilot CLI and want Docker access without the "hope nothing goes wrong" approach, the deep dive on how the broker works is linked in the comments. And if you find it useful, a star on GitHub helps more than you'd think. #Docker #DevOps #OpenSource #GitHubCopilot #Security
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
-
Stop running heavy jobs on every branch — target them precisely. 🚦 This article shows how to configure GitHub Actions so workflows and jobs run only on the branches you want. It covers branch filters, wildcards, ignores, manual triggers, and job-level conditions. Key takeaways: - Use on.branches to trigger only on branches like main or dev 🔧 - Wildcards: feature/* and releases/** to match patterns ✨ - branches-ignore to exclude experimental branches ❌ - Use needs + if: github.ref == 'refs/heads/main' to run deploys only after tests pass ✅ Read for copy-paste YAML examples and clean CI/CD control: https://lnkd.in/eyteNsfs #GitHubActions #CICD #DevOps #GitHub #SRE
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 related topics
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