是否可以从 R 脚本内部运行 git 命令?

use*_*256 6 git r system

下面是 git 中传统工作流程的描述。

是否有可能以某种方式在 R 中编写一个脚本,让 git 执行所有脚本?这样做是否明智?非常感谢!

  1. 在项目目录中创建/修改文件。
  2. 在命令行中,通过输入 更改目录cd <path_to_local_repository>
  3. 在命令行中输入git add --all以暂存更改。
  4. git commit -m '<commit_message>'在命令行输入以将更改提交到本地存储库。
  5. git push 在命令行中输入,将更改推送到远程存储库(例如,在 Bitbucket 上)。
  6. 如果提示进行身份验证,请输入您的 Bitbucket 密码。

Rus*_*yde 5

“git2r”包提供了这种功能:https://docs.ropensci.org/git2r/reference/checkout.html

创建文件/目录和更改目录可以在基本 R 中使用 file.create 和 setwd 等完成

然后:

git2r::add(repo = ".", path = NULL, force = FALSE)
git2r::commit(repo = ".", message = "commit message")
git2r::push(credentials = whatever-you-need-for-pushing-to-bitbucket)

Run Code Online (Sandbox Code Playgroud)