I want to dave or change a file with ruby, thats no problem. But this file is part of a git repository that needs to be commited after the change. How can I achieve that with the ruby script?
Call a shell command in your ruby script. There are lots of ways to execute a shell command in ruby. Backticks are one of them. Look at this Calling shell commands from Ruby for more.
`git commit -am "Committing from ruby script"`
Just use a Git library like ruby-git
- establish the repo in a temp folder, pull the project into it, change the file, commit it, push it, and delete the repo. (Assuming it's a rare operation. If not, you should probably establish a permanent repo folder and just keep pulling, committing, and pushing it.)
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.