[英]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.