简体   繁体   English

如何使用shell脚本自动将文件推送到git repo

[英]how to Auto push files to git repo using shell script

I am new to GIT..I have a requirement where we need to select few files from a dir and push those files to git repository using a shell script? 我是GIT的新手。我有一个需求,我们需要从目录中选择一些文件,然后使用Shell脚本将这些文件推送到git存储库中? Can any one help me out on how to achieve this? 谁能帮助我实现这一目标? Can we automate this process using Jenkins? 我们可以使用Jenkins自动执行此过程吗? That is, whenever we trigger jenkins job, that should select the required files based on some file format and push those to GIT repo? 也就是说,无论何时触发jenkins作业,都应该根据某种文件格式选择所需的文件,然后将其推送到GIT存储库中? Thank you in advance 先感谢您

To answer the title question, here's a tiny bash example that will push files 为了回答标题问题,这是一个小小的bash示例,它将推送文件

#!/bin/bash

# add files you want to push here
# git add <stuff>

git push 

Martin's comment seems to wholeheartedly say yes to the jenkins sidenote, but that might be better suited in another question, unless you find this useful 马丁的评论似乎全心全意地对詹金斯的旁注说“是”,但这可能更适合另一个问题,除非您发现很有用

sidenote: a bash/git boilerplate i've found useful is this: 旁注:我发现有用的bash / git样板是这样的:

#!/bin/bash

function pushIt () {
  # maybe some stuff before the push?
  # if so, add it here
  git push 
} 

# this is a convenient check for uncommitted changes, 
# a handy thing if the script's expected to grow
if [ -z "$(git status --porcelain)" ];then
  pushIt
else
  echo "Repo isn't clean, commit or stash your changes"
fi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用带有用户名和密码的 shell 脚本克隆 git 存储库 - How to clone git repo using shell script with username and password 如何使用CLI(Shell脚本)将现有的git repo从本地服务器转移到gitlab repo? - How to transfer existing git repo from local server to gitlab repo, using CLI(Shell script)? 无法使用git commit推送到分叉的仓库和使用脚本推送 - Unable to push to forked repo using git commit and push using a script 如何使用shell脚本从git仓库打印最新的提交ID - How to print the latest commit ID from the git repo using shell script 将本地存储库推送到远程控制器不会使用GIT推送子模块文件 - Pushing local repo to remote does not push submodule files using GIT 使用其他用户帐户将文件推送到git远程仓库中 - push files into git remote repo using different user account Git Repo自动提交和推送 - Git Repo Auto-commit and Push 如何忽略大文件并推送到git repo - How can I ignore big files and push to git repo 如何使用 terraform 克隆 git 存储库、更新文件并向其推送提交? - How to use terraform to clone a git repo, update files, and push commits to it? 如何删除 git repo 中的所有文件并从本地 git repo 更新/推送? - How can I remove all files in my git repo and update/push from my local git repo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM