Powerapps 解决方案无法通过 git 向开发人员提交最新更改

Powerapps solution failing to commit latest changes to dev via git

运行 PowerApps 解决方案的 AzureDevOp 管道问题。最初能够毫无问题地将解决方案文件添加到源代码管理,然后从中创建一个开发分支以继续向开发分支提交更改。

这是用于向源代码管理添加解决方案的代码:

echo commit all changes
git config user.email "EMAIL@EMAIL"
git config user.name "Automatic Build"
git checkout DevBranch
git add --all
git commit -m "Committing all changes"
echo push code to new repo
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" push origin DevBranch

现在失败,退出代码为 1,我真的不明白为什么。 git 代码错误表示:

commit all changes
error: Your local changes to the following files would be overwritten by checkout:
    XXX_8cec2.meta.xml
    XXX_8cec2_DocumentUri.msapp
Please commit your changes or stash them before you switch branches.
Aborting
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

[detached HEAD 0425626] Updating branch code for powerapps
2 files changed, 3 insertions(+), 3 deletions(-)
push dev code to repo
! [rejected] Dev -> Dev (non-fast-forward)
error: failed to push some refs to 'https://LINK
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
##[error]Cmd.exe exited with code '1'.
##[section]Finishing: Push to Repo

任何 suggestion/help 非常感谢。谢谢

Powerapps solution failing to commit latest changes to dev via git

根据错误提示,本地修改的代码似乎会被git上的代码通过切换分支覆盖。

要解决此问题,请传递 -f (force) 标志以强制签出分支,这将清除您所做的所有尚未提交的更改:

git checkout -f branch

或者您可以尝试通过提交更改文件来覆盖本地:

查看当前分析,如master:

git branch

提交修改代码:

git add .
git commit -m “add all”
git push origin master

切换分支:

git chechout xxx

而如果不想提交,也可以使用gitstash将当前工作区内容保存在git栈中:

git stash

查看 了解更多详情。