0

I have a PHP project (an wordpress plugin). When i need to publish this project to a remote test or production server, I have to send files through common FTP. In order not to upload all files, I'd like to obtain only modified files from the last build.

Is there an way to use GIT to, given two different branches or commits, create a folder with files changed or added between this two branches/commit. This would give me all files I have to upload.

I've tried using git diff branch1..branch2 > result.diff, but that would give me a single text file with all changes, and that wont't help with the FTP upload process, I'd like to copy all changed/added files to a folder, following the same folder structure, so i could just upload this folder.

Edit:

Based on @LeGEC answer, I wrote a little command line utility that read the results of gitDiff and generate a folder with the files. If someone is interested, its on GitHub:

https://github.com/marlonbrum/Br1.GitPack

Marlon
  • 1,719
  • 3
  • 20
  • 42
  • `git diff --stat` will show you the list of changed files. Copy them from the branch (working directory) and share as you wish. – 0andriy Feb 19 '20 at 13:10
  • Does this answer your question? [May I list the files of the current commit?](https://stackoverflow.com/questions/46205090/may-i-list-the-files-of-the-current-commit) – LeGEC Feb 19 '20 at 13:30

1 Answers1

1

You can try one of :

git diff --name-only
git diff --name-status

and see which one suits your needs the best.


git diff also has a --diff-filter option, which you probably want to combine with --no-renames in this situation, so that a renamed file correctly appears in the "deleted" list :

# list the files whose content has been modified, and should be copied :
git diff --no-renames --name-only --diff-filter=ACM

# list the files that have been deleted from the repo, and should be *removed* :
git diff --no-renames --name-only --diff-filter=D
LeGEC
  • 46,477
  • 5
  • 57
  • 104