Explore Courses Blog Tutorials Interview Questions
+1 vote
in DevOps and Agile by (29.3k points)

My git workspace is dirty, there are some local modifications. When I use the command

 git pull origin master 

it works fine because there is no conflict.

But when I'm trying to use Ansible like

 git: repo=xxxx dest=xxx version={{branch}} 

I got error

Local modifications exist in repository (force=no)

If I add force=yes, then I will lose my local modifications.

What can I do to keep my local changes and pull the latest commit from git by using the Ansible git module?

1 Answer

0 votes
by (50.2k points)
edited by

You cannot use this in the git module because ansible will check the results of 

git status --porcelain

And abort this task execution If there are any local changes in tracked files 

The only way is using shell command or tries to keep a clean workspace. Because there is no other module that will execute git pull and git module will not allow this execution.

For more information please go through the following tutorial to get more info about git:

Browse Categories