Add & Commit
You can use this GitHub Action to commit changes made in your workflow run directly to your repo: for example, you use it to lint your code, update documentation, commit updated builds, etc...
Table of contents
Inputs
Add a step like this to your workflow:
- uses: EndBug/add-and-commit@v9 # You can change this to use a specific version. with: # The arguments for the `git add` command (see the paragraph below for more info) # Default: '.' add: 'src' # The name of the user that will be displayed as the author of the commit. # Default: depends on the default_author input author_name: Author Name # The email of the user that will be displayed as the author of the commit. # Default: depends on the default_author input author_email: mail@example.com # Additional arguments for the git commit command. The --message argument is already set by the message input. # Default: '' commit: --signoff # The name of the custom committer you want to use, if different from the author of the commit. # Default: the name of the author (set with either author_name or default_author) committer_name: Committer Name # The email of the custom committer you want to use, if different from the author of the commit. # Default: the email of the author (set with either author_email or default_author) committer_email: mail@example.com # The local path to the directory where your repository is located. You should use actions/checkout first to set it up. # Default: '.' cwd: './path/to/the/repo' # Determines the way the action fills missing author name and email. Three options are available: # - github_actor -> UserName <UserName@users.noreply.github.com> # - user_info -> Your Display Name <your-actual@email.com> # - github_actions -> github-actions <email associated with the github logo> # Default: github_actor default_author: github_actor # Arguments for the git fetch command. If set to false, the action won't fetch the repo. # For more info as to why fetching is usually recommended, please see the "Performance on large repos" FAQ. # Default: --tags --force fetch: false # The message for the commit. # Default: 'Commit from GitHub Actions (name of the workflow)' message: 'Your commit message' # If this input is set, the action will push the commit to a new branch with this name. # Default: '' new_branch: custom-new-branch # The way the action should handle pathspec errors from the add and remove commands. Three options are available: # - ignore -> errors will be logged but the step won't fail # - exitImmediately -> the action will stop right away, and the step will fail # - exitAtEnd -> the action will go on, every pathspec error will be logged at the end, the step will fail. # Default: ignore pathspec_error_handling: ignore # Arguments for the git pull command. By default, the action does not pull. # Default: '' pull: '--rebase --autostash ...' # Whether to push the commit and, if any, its tags to the repo. It can also be used to set the git push arguments (see the paragraph below for more info) # Default: true push: false # The arguments for the `git rm` command (see the paragraph below for more info) # Default: '' remove: './dir/old_file.js' # Arguments for the git tag command (the tag name always needs to be the first word not preceded by an hyphen) # Default: '' tag: 'v1.0.0 --force' # Arguments for the git push --tags command (any additional argument will be added after --tags) # Default: '' tag_push: '--force'
Git arguments
Multiple options let you provide the git
arguments that you want the action to use. It's important to note that these arguments are not actually used with a CLI command, but they are parsed by a package called string-argv
, and then used with simple-git
.
What does this mean for you? It means that strings that contain a lot of nested quotes may be parsed incorrectly, and that specific ways of declaring arguments may not be supported by these libraries. If you're having issues with your argument strings you can check whether they're being parsed correctly either by enabling debug logging for your workflow runs or by testing it directly with string-argv
(RunKit demo): if each argument and option is parsed correctly you'll see an array where every string is an option or value.
Adding files
The action adds files using a regular git add
command, so you can put every kind of argument in the add
option. For example, if you want to force-add a file: ./path/to/file.txt --force
.
The script will not stop if one of the git commands doesn't match any file. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
You can also use JSON or YAML arrays (e.g. '["first", "second"]'
, "['first', 'second']"
) to make the action run multiple git add
commands: the action will log how your input has been parsed. Please mind that your input still needs to be a string because of how GitHub Actions works with inputs: just write your array inside the string, the action will parse it later.
Deleting files
The remove
option can be used if a predetermined list of files needs to be removed. It runs the git rm
command, so you can pass every kind of argument with it. As if with the add
input, you can also use JSON or YAML arrays to make the action run multiple git rm
commands.
If you want deleted files to be auto-detected and committed, you can use the --no-ignore-removal
/-A
git arguments.
Pushing
By default the action runs the following command: git push origin ${new_branch input} --set-upstream
. You can use the push
input to modify this behavior, here's what you can set it to:
true
: this is the default value, it will behave as usual.false
: this prevents the action from pushing at all, nogit push
command is run.- any other string:
The action will use your string as the arguments for thegit push
command. Please note that nothing is used other than your arguments, and the command will result ingit push ${push input}
(no remote, no branch, no--set-upstream
, you have to include them yourself).
One way to use this is if you want to force push to a branch of your repo: you'll need to set the push
input to, for example, origin yourBranch --force
.
Creating a new branch
If you want the action to commit in a new branch, you can use the new_branch
input.
Please note that if the branch exists, the action will still try push to it, but it's possible that the push will be rejected by the remote as non-straightforward.
If that's the case, you need to make sure that the branch you want to commit to is already checked out before you run the action.
If you're really sure that you want to commit to that branch, you can also force-push by setting the push
input to something like origin yourBranchName --set-upstream --force
.
If you want to commit files "across different branches", here are two ways to do it:
- You can check them out in two different directories, generate your files, move them to your destination and then run
add-and-commit
in the destination directory using thecwd
input. - You can manually commit those files with
git
commands as you would on your machine. There are several ways to do this depending on the scenario. One of them if to stash your changes, checkout the destination branch, and popping the stash. You can then use theadd-and-commit
action as usual. Please note that this is just an example and may not work for you, since your use case may be different.
Tagging
You can use the tag
option to enter the arguments for a git tag
command. In order for the action to isolate the tag name from the rest of the arguments, it should be the first word not preceded by an hyphen (e.g. -a tag-name -m "some other stuff"
is ok).
You can also change the arguments of the push command for tags: every argument in the tag_push
input will be appended to the git push --tags
command.
For more info on how git arguments are parsed, see the "Git arguments" section.
Outputs
The action provides these outputs:
committed
: whether the action has created a commit ('true'
or'false'
)commit_long_sha
: the full SHA of the commit that has just been createdcommit_sha
: the short 7-character SHA of the commit that has just been createdpushed
: whether the action has pushed to the remote ('true'
or'false'
)tagged
: whether the action has created a tag ('true'
or'false'
)tag_pushed
: whether the action has pushed a tag ('true'
or'false'
)
For more info on how to use outputs, see "Context and expression syntax".
FAQs
Working with PRs
By default, when you use actions/checkout
on a PR, it will checkout the head commit in a detached head state.
If you want to make some changes, you have to checkout the branch the PR is coming from in the head repo.
You can set it up like this:
- uses: actions/checkout@v4 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }}
You can find the full docs for payloads of pull_request
events here.
If you're planning on running this only on "internal" PRs (where head and base are in the same repo) then you can omit the repository
input.
If you're planning to use this with PRs coming from other forks, please keep in mind that you might not have write access to those repos.
You can try setting up the repo with your PAT, as explained in the "About tokens" paragraph of this section.
Keep in mind that this "custom checkout" is meant only for PRs: if your workflow runs on multiple events (like push
or workflow_dispatch
), you could try having this step run only for pull_request
events, while other ones will trigger the usual checkout.
If you wish to do so, you can use the step.if
property, here's the docs.
About tokens
When pushing, the action uses the token that the local git repository has been configured with: that means that if you want to change it you'll need to do it in the steps that run before this action. For example: if you set up your repo with actions/checkout
then you have to add the token there.
Changing the token with which the repo is configured can be useful if you want to run CI checks on the commit pushed by this action; anyway, it has to be set up outside of this action.
The action automatically gets the GitHub token from a github_token
input: this input should not be modified by the user, since it doesn't affect the commits as it's only used to access the GitHub API to get user info, in case they selected that option for the commit author.
The commit from the action is not triggering CI!
That's because you're checking out the repo using the built-in GITHUB_TOKEN
secret: GitHub sees that the push event has been triggered by a commit generated by CI, and doesn't run any further checks to avoid unintentional check loops.
If you're sure that you want the commits generated during CI to trigger other workflow runs, you can checkout the repo using a Personal Access Token (PAT): this will make the resulting commit the same as if you made it yourself.
If you're using actions/checkout
, check out their docs to see how to set your repo token.
About actions/checkout
The token you use when setting up the repo with this action will determine what token add-and-commit
will use.
Some users reported that they were getting an error:
> fatal: could not read Username for 'https://github.com': No such device or address
If you're getting this error and you're using actions/checkout@v1
, try upgrading to actions/checkout@v2
. If you're still having problems after upgrading, feel free to open an issue. Issue ref: #146
Performance on large repos
By default, the action will fetch the repository before starting to work on it: this ensures that it can see the already existing refs.
When working with a repository that has a lot of branches and tags, fetching it can take a long time. If the fetch step is taking too much time, you can decide to skip it by setting the fetch
input to false
: this will prevent the action from running git fetch
altogether.
Please note that you have to set up your workflow accordingly: not fetching the repo can impact branch and tag creation within the action, and for this reason it's recommended to disable it only if necessary. Issue ref: #386
Examples
Different author/committer configurations
If you don't want to use your GitHub username for the CI commits, you can use the default_author
input to make it appear as if it was made by "GitHub Actions", by setting its value to github_actions
.
on: push jobs: build: runs-on: ubuntu-latest steps: - uses: EndBug/add-and-commit@v9 with: default_author: github_actions
You can also use the committer_name
and committer_email
inputs to make it appear as if GitHub Actions is the committer, here are a couple of example steps:
<img src="https://user-images.githubusercontent.com/26386270/130594443-b881fae7-3064-4020-a4cc-6db37ef0df65.png" height=70/>- uses: EndBug/add-and-commit@v9 with: message: Show GitHub Actions logo committer_name: GitHub Actions committer_email: actions@github.com
- uses: EndBug/add-and-commit@v9 with: message: Show GitHub logo committer_name: GitHub Actions committer_email: 41898282+github-actions[bot]@users.noreply.github.com
Array inputs
Due to limitations in the GitHub action APIs, all inputs must be either strings or booleans.
The action supports arrays in add
and remove
, but they have to be encoded as a string with a YAML flow sequence:
- uses: EndBug/add-and-commit@v9 with: add: '["afile.txt", "anotherfile.txt"]'
(note the single-quotes) or a YAML block sequence:
- uses: EndBug/add-and-commit@v9 with: add: | - afile.txt - anotherfile.txt
(Note the pipe character making it a multiline string.)
Automated linting
Do you want to lint your JavaScript files, located in the src
folder, with ESLint, so that fixable changes are done without your intervention? You can use a workflow like this:
name: Lint source code on: push jobs: run: name: Lint with ESLint runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 - name: Install dependencies run: npm install - name: Update source code run: eslint "src/**" --fix - name: Commit changes uses: EndBug/add-and-commit@v9 with:
编辑推荐精选

酷表ChatExcel
大模型驱动的Excel数据处理工具
基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


DeepEP
DeepSeek开源的专家并行通信优化框架
DeepEP是一个专为大规模分布式计算设计的通信库,重点解决专家并行模式中的通信瓶颈问题。其核心架构采用分层拓扑感知技术,能够自动识别节点间物理连接关系,优化数据传输路径。通过实现动态路由选择与负载均衡机制,系统在千卡级计算集群中维持稳定的低延迟特性,同时兼容主流深度学习框架的通信接口。


DeepSeek
全球领先开源大模型,高效智能助手
DeepSeek是一家幻方量化创办的专注于通用人工智能的中国科技公司,主攻大模型研发与应用。DeepSeek-R1是开源的推理模型,擅长处理复杂任务且可免费商用。


问小白
DeepSeek R1 满血模型上线
问小白是一个基于 DeepSeek R1 模型的智能对话平台,专为用户提供高效、贴心的对话体验。实时在线,支持深度思考和联网搜索。免费不限次数,帮用户写作、创作、分析和规划,各种任务随时完成!


KnowS
AI医学搜索引擎 整合4000万+实时更新的全球医学文献
医学领域专用搜索引擎整合4000万+实时更新的全球医学文献,通过自主研发AI模型实现精准知识检索。系统每日更新指南、中英文文献及会议资料,搜索准确率较传统工具提升80%,同时将大模型幻觉率控制在8%以下。支持临床建议生成、文献深度解析、学术报告制作等全流程科研辅助,典型用户反馈显示每周可节省医疗工作者70%时间。


Windsurf Wave 3
Windsurf Editor推出第三次重大更新Wave 3
新增模型上下文协议支持与智能编辑功能。本次更新包含五项 核心改进:支持接入MCP协议扩展工具生态,Tab键智能跳转提升编码效率,Turbo模式实现自动化终端操作,图片拖拽功能优化多模态交互,以及面向付费用户的个性化图标定制。系统同步集成DeepSeek、Gemini等新模型,并通过信用点数机制实现差异化的资源调配。


腾讯元宝
腾讯自研的混元大模型AI助手
腾讯元宝是腾讯基于自研的混元大模型推出的一款多功能AI应用,旨在通过人工智能技术提升用户在写作、绘画、翻译、编程、搜索、阅读总结等多个领域的工作与生活效率。


Grok3
埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型
Grok3 是由埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型,常被马斯克称为“地球上最聪明的 AI”。它不仅是在前代产品 Grok 1 和 Grok 2 基础上的一次飞跃,还在多个关键技术上实现了创新突破。


OmniParser
帮助AI理解电脑屏幕 纯视觉GUI元素的自动化解析方案
开源工具通过计算机视觉技术实现图形界面元素的智能识别与结构化处理,支持自动化测试脚本生成和辅助功能开发。项目采用模块化设计,提供API接口与多种输出格式,适用于跨平台应用场景。核心算法优化了元素定位精度,在动态界面和复杂布局场景下保持稳定解析能力。


流畅阅读
AI网页翻译插件 双语阅读工具,还原母语级体验
流畅阅读是一款浏览器翻译插件,通过上下文智能分析提升翻译准确性,支持中英双语对照显示。集成多翻译引擎接口,允许用户自定义翻译规则和快捷键配置,操作数据全部存储在本地设备保障隐私安全。兼容Chrome、Edge、Firefox等主流浏览器,基于GPL-3.0开源协议开发,提供持续的功能迭代和社区支持。
推荐工具精选
AI云服务特惠
懂AI专属折扣关注微信公众号
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号