我有一个 bitbucket 存储库,它使用 bitbucket-pipelines 部署到 azure 上的本地存储库(用于我们的开发服务器)。我正在研究管道在部署到天蓝色之前将使用的构建步骤。我的构建步骤现在唯一要做的就是将构建文件输出到给定的 gitignored 目录中。然后它强制添加 gitignored 构建文件夹。然后它会修改触发管道的提交,最后强制将提交推送到 master。
所以我的文件看起来像这样
# bitbucket decided to make the repository shallow this line
# makes the repo unshallow so we can push later
- git fetch https://<bitbucket-repo> --unshallow
# doing some setup so we can run the build scripts
- npm install
- npm install -g gulp
# just building files for now we can add tests in later
- npm run build:single
# forcing the build files to be included in the commit
# so that azure has access to the files.
- git add --force public/build/
# do some git configuration so it will let us commit
- git config --global user.email $GIT_USER_EMAIL
- git config --global user.name "\$GIT_USER_NAME"
# add to the last commit so we can keep its message
# this is so we can see the last commit message that was
# done on azure without creating a new commit message
# this command edits the previous commit and should
# never be done when that commit has already been
# pushed to your target branch and if your target branch is
# public.
- git commit --amend --no-edit
# the below line pushes to a branch on azure we setup as a local branch
- git push --force https://<azure-branch-repo> master
我的问题是:
我会用这个 git 工作流程破坏任何东西吗?你有什么建议吗?
我想只有我的管道脚本才会推送到 azure 的本地仓库,所以可以修改提交,否则如果其他人推送到它,这可能是个坏主意。这是我应该关心的事情吗?我想保留原始提交消息,因为 azure 将其显示在以前的部署列表中。如果他们都有与他们的 bitbucket 提交相关的部署名称,那么返回到某个部署会变得更加简单。
我也想知道这是否是一个可以使用的好时机,git push --force
因为我听说--force
国旗被认为是危险的。由于我为每个部署将构建文件提交到 git,我将有一个偏离 repo 的提交,其中包含所有构建文件。我的想法是使用--force
会忘记最后一次杂散提交,并按照 bitbucket-pipelines 构建它的方式拥有一切。我不确定我的解释--force push
是否正确。