为什么Git需要快速进行VSTFS构建?

时间:2016-11-21 20:54:31

标签: git azure-devops fast-forward

我正在开发我们的dev VSTFS Git存储库中的一些数据。当我运行构建时,当然构建目录被擦除,与Git repo同步,数据从外部源下载,然后被推回到Git。

然而,每当这种情况发生时,即使我在推动之前做了Git拉动,它也会说我落后并且需要快进。所以我做了一个Git pull -ff。

但是,我想更多地了解为什么会发生这种情况。是因为每次都擦除目录吗?

这是构建: https://drive.google.com/file/d/0B8bQlVTjVjdoSWR6ZkhGOVNTd0U/view?usp=sharing

您可以忽略仅检索数据的Powershell。

这是批处理文件

ECHO ADD GIT TO PATH
PATH %PATH%;C:\Program Files\Git\cmd
ECHO TEST PATH
set PATH
ECHO GIT STATUS
git status
ECHO GIT CHECKOUT MASTER
git checkout master
ECHO GIT PULL FASTFORWARD
git pull origin master -ff
ECHO GIT ADD ALL
git add -A
ECHO GIT COMMIT ALL
git commit -m "Backing up Octopus P01 and P02"
ECHO GIT PUSH
git push origin master

没有-ff

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'http://xxxxxx:8080/tfsdev/xxxxx/_git/Development.Services'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我发现解决此问题的另一种方法是在构建中的存储库设置中选择Clean = true。这包括清理和重置

Syncing repository: Development.Services (Git)
Running 'git clean -fdx' on D:\BuildAgents\_work\7\s.
Running 'git reset --hard HEAD' on D:\BuildAgents\_work\7\s.
HEAD is now at ****** Updated GitTest.bat
Starting fetch...
Checking out ****** to D:\BuildAgents\_work\7\s
Checked out branch refs/heads/master for repository Development.Services at commit ******

1 个答案:

答案 0 :(得分:0)

根据日志,有些更改没有为提交导致问题的提交进行。您可以在构建之前清理存储库。

enter image description here

相关问题