Search code examples
bashgitantsalesforcecommit

Bash for copying files committed by git


I would like to ask whether it is possible to do this:

Folder 1

  • Class 1
  • Class 2
  • Class 3

Folder 2

  • empty

Class 1 and Class 2 are modified, then committed to git repository (can work also for push). At this moment I need to automatically using bash script copy these two classes from Folder 1 to Folder 2. Eventually I also need to create an xml file where I will have something like:

<classes>
   Class 1
   Class 2
</classes>

But the xml is a second step and now I need to know whether is the first step even possible. I read about git archive but this would create an archive of the commit which is not what I need. Are there any other possibilities?

Thanks in advance, David


Solution

  • All this fuss should be used for deployment among certain environments. And I need to deploy only what was changed.

    Then a git diff --name-only @~ -- Folder1 is enough to give you a list of what has changed in Folder1.

    From that list, your script can build the right Folder2 content, and the right xml file.