git - git 仅添加 master 中尚未跟踪的文件
问题描述
是否有一个命令仅用于暂存分支尚未git
跟踪的文件(具有特定扩展名) ?main
我的具体用例是在 PR 上触发的 GitHub 操作,该操作使用压缩 SVG 资产,svgo
但前提是这些资产尚未在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'
解决方案
推荐阅读
- apache-camel - 使用 Apache camel 集成 Rest API
- logic - 如何对 Isabelle/HOL 中的变量变化(世界变化)进行建模/形式化?
- python-3.x - 如何在机器人框架中存储从列表返回的值应该包含子列表?
- django - 如何将列表从后端发送到 django 模板?
- javascript - 使用浏览器的导入编译 TypeScript 文件
- css - React Select:如何用我自己的图像替换 loadingIndicator 点
- c# - 如何将项目添加到我自己创建的控件
- javascript - 将类中的状态转换为反应中的功能的问题
- image - Flutter:什么样的参数类型可以分配参数类型“图像函数(动态)”?
- xamarin.forms - 如何在 Xamarin Forms 中的 ArcGIS Runtime 中为 TextSymbol 设置 FontFamily