Skip to main content

3 posts tagged with "git"

View All Tags

Run git action locally

· 2 min read

To run a GitHub Action locally, you can use tools like Act. Act is a popular utility that lets you execute GitHub Actions workflows on your local machine.

Steps to Run a GitHub Action Locally:

  1. Install Act You can install Act using a package manager or by downloading a binary:

    • Linux/macOS (via Homebrew):
      brew install act
    • Linux/macOS/Windows (via binary): Download from the Act Releases page.
  2. Verify Installation Ensure Act is installed correctly:

    act --version
  3. Prepare Your Repository

    • Make sure your repository contains a .github/workflows/ directory with your GitHub Action workflows.
  4. Provide Secrets (If Needed) If your workflow uses secrets, create a .secrets file in the root of your repository:

    MY_SECRET=your-secret-value

    Or pass secrets directly via the command line:

    act --secret MY_SECRET=your-secret-value
  5. Run the Workflow To run the default workflow (push event):

    act

    To run a specific event:

    act <event_name>

    For example:

    act pull_request
  6. Use Custom Runner Images (Optional) By default, Act uses a lightweight image. If your workflow requires a specific environment, use a custom image:

    act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04

Notes:

  • Dependencies: Ensure your local environment has all required dependencies installed for the workflow to execute correctly.
  • Docker Requirement: Act uses Docker to emulate GitHub Actions environments. Make sure Docker is installed and running on your system.

This approach helps you test and debug your GitHub Actions workflows locally without pushing changes to the repository.

Exclude files from git diff

· One min read

Exclude specific files from git diff

git diff -wu ${hash} -- . ':(exclude)a' ':(exclude)dir/b'

Explanation

  • git diff -wu : Show the changes between two commits, ignoring whitespace
  • ${hash} : Commit hash
  • -- : Separate the commit hash from the file paths
  • . : Include all files in the current directory
  • ':(exclude)a' : Exclude file a

Set up Meld as Difftool and Mergetool for Git

· One min read

Configure Meld as Default Git Tools

Edit Config File

  • .gitconfig
[merge]
tool = meld
[mergetool "meld"]
# Choose one of these 2 lines
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"

Commands for Windows and Linux

  • for Windows
git config --global diff.tool meld
git config --global difftool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
git config --global difftool.prompt false

git config --global merge.tool meld
git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
git config --global mergetool.prompt false
  • For Linux
git config --global diff.tool meld
git config --global difftool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
git config --global difftool.prompt false

git config --global merge.tool meld
git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
git config --global mergetool.prompt false