Git Auto pull from Azure Repos and run on VM

Issue

I am not very good at Git, I have a project to run same python code located in AzureDevops Repos on multiple VMs.
How can I create a .bat file that pulls code from AzureDevops Repo and run on VM? I need it because in case there are some changes needed to be applied on the code, I will not need to go to each VM to change and save it.

Solution

If you want to use .bat file to pulls code from AzureDevops Repo and run on VM through command, please see whether the following steps help:

1.Click the ‘copy’ icon to get the URL.
enter image description here

2.Go to the folder that you would like to save the .bat file and the git file. Create a .txt file and write ‘git clone URL’ in it, save and close, modify the file name as ***.bat.
enter image description here

Create a .txt file and write the added content(here I use it as example, you could add wanted command here), then do ‘git add .”git commit -m""’and ‘git push’.save and close, modify the file name as *****.bat.

cd a1p
echo hello world(echo to add content) >> README.md (the modified file name)
echo How are you? >> README.md
type README.md
git add .
git commit -m"goodcommit1"(name your commit)
git push

3.Double click ***.bat first and after it finishes, click *****.bat file.
you will get things like this when double click the ***.bat file:

enter image description here

It will automatically close when finishing the clone. And here you could see the folder named a1p in the target folder.
Then double click *****.bat file, after it finish, you will see these like this in the README file:

enter image description here

Push the changes to your repo then you could pull it to other VMs with the changes. Hope it could do some help.

Answered By – Antonia Wu-MSFT

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published