How to use Ansible git module pull a branch with local changes?

0 votes

I have made some local modifications. When I use 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 latest commit from git by using Ansible git module.

Can anyone help me with this ?

Jul 9, 2018 in Ansible by shubham
• 6,910 points
3,122 views

1 answer to this question.

0 votes

You cannot achieve it using the git module.

Here is what happens:

Ansible checks the result of:

git status --porcelain

and aborts task execution if there are local changes in tracked files, unless force parameter is set to true.

I hope that above information would be helpful for you.

answered Jul 9, 2018 by Atul
• 10,240 points

Related Questions In Ansible

0 votes
0 answers

How to pull a docker image using Ansible playbook?

Hi Guys, I am new in Ansible. I ...READ MORE

Aug 4 in Ansible by akhtar
• 25,570 points
280 views
0 votes
1 answer

How to replace a line using lineinfile module in Ansible?

Hi@MD, You can use lineinfile module in Ansible. ...READ MORE

answered Sep 2 in Ansible by akhtar
• 25,570 points
50 views
0 votes
1 answer

How to make a file executable with Ansible?

Hi@akhtar, You can use the file module in ...READ MORE

answered Sep 16 in Ansible by MD
• 57,960 points
13 views
0 votes
1 answer

How to start a docker container with healthstatus using Ansible?

Hi@akhtar, You can use the docker_container module in ...READ MORE

answered Sep 20 in Ansible by MD
• 57,960 points
24 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
687 views
+2 votes
1 answer
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
6,187 views
0 votes
1 answer