0

I am new to Git. I have a public repo in GitHub which i like to sync with my Azure Git. The scenario is like below

GitHub has multiple folders and files with no parent folder. I want to have these folders, files copied to my Azure Git using Azure CI CD process under a parent folder only.

I tried to depict in attached diagram. Git Process

How can i achieve this? Code snippet would help me better as i am new to Git.

Note: I have to use the Azure CI CD process hence there wont be any permanent place where I can put up the code/branches. It would always run in Build Agent which will change in every execution.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

Since I am using the Azure CI CD process, I don’t need to pull specifically the source code at least. Its handled by the Build pipeline. Next are the few steps which I figured out on my own (lot of hit and trial) to handle the situation mentioned in question.

Basically I moved the content of source repository (GitHub repo content) to a folder (Parent Folder "Y") having same name as of the Parent Folder in destination Azure Git. And then pushed the content of this newly created folder.

  1. robocopy $(System.DefaultWorkingDirectory) $(Agent.WorkFolder)\Parent Folder Y\ /e /move

This Parent Folder Y is the parent folder name under which I wanted to push the changes in my Azure Git (Destination).

  1. robocopy $(Agent.WorkFolder)\Parent Folder Y $(System.DefaultWorkingDirectory)\Parent Folder Y\ /e /move

  2. cd $(System.DefaultWorkingDirectory)\"Parent Folder Y"

  3. git pull https://$(token)@xyzteam.visualstudio.com/_git/Your_Repo _Name BranchName

  4. git push https://$(token)@xyzteam.visualstudio.com/_git/Your_Repo _Name head:BranchName