如何解决git add 只添加尚未在 master 中跟踪的文件
git
是否有用于暂存尚未被 main
分支跟踪的文件(具有特定扩展名)的命令?
我的具体用例是在 PR 上触发的 GitHub 操作,该操作使用 svgo
压缩 SVG 资产,但前提是这些资产尚未在 main
中。
name: SVG Compression
on:
pull_request:
branches:
- master
paths:
- '**.svg' # only run workflow when SVG files changed
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up node
uses: actions/setup-node@v2
- name: Install Svgo
run: |
npm -g svgo
- name: Compress new SVG assets and commit to current PR
run: |
svgo assets/*
# how to `git add` only if the file is new to the `main` branch?
# ignore files with small but irrelevant diffs from repeated compression
git add assets/*.svg
git commit -m 'compress new SVG assets'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。