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? Can any one help me out on how to achieve this? Can we automate this process using 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? Thank you in advance
To answer the title question, here's a tiny bash example that will push files
#!/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:
#!/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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.