2016-11-21 42 views
0

我正在备份我们的开发VSTFS Git存储库中的一些数据。当我运行构建时,当然构建目录被擦除,与Git仓库同步,​​数据从外部源下载,然后推回到Git。为什么Git需要快速进行VSTFS构建?

但是,每次发生这种情况时,即使我在推动之前先做Git pull,它也会说我落后了,需要快速前进。所以我做了一个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. 

另一种方式,我发现解决这个是选择清洁=真正在构建存储库设置。这包括清理和重置

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 ****** 
+0

您在构建之前还是之后拉动?什么是事件的确切顺序?你是否正在遵循这个指南? https://www.visualstudio.com/en-us/docs/git/gitquickstart – Schwern

+0

为了更清楚地说明,这是在Web门户中,而不是在Visual Studio中。 – user1869558

+0

拉动发生在构建。 – user1869558

回答

0

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

enter image description here