我正在为 Jenkins 作业开发自动化脚本。该脚本接受一个参数$1
,对存储库文件进行小的更改并推送更改。它只是这样做:
git clone repo
echo > $1
git commit -a -m 'updated'
git push
当这些 Jenkins 作业立即执行时,git push
经常会失败:
! [rejected] master -> master (non-fast-forward)
这是完全可以理解的。但我想强制推动发生,因为已经保证每个脚本调用都会得到不同的$1
.
从手册页中,我了解到:
--force
... This flag disables these checks,
and can cause the remote repository to lose commits;
use it with care.
该标志是否适合我的场景?