Using Git to create an archive of changed files

后端 未结 3 509
醉梦人生
醉梦人生 2020-12-25 08:22

I am looking for a simple solution to make a archive of recent changed file.

I get this simple command from google

git archive -o update.zip HEAD $(g         


        
相关标签:
3条回答
  • 2020-12-25 08:58

    You just need to filter out files deleted while that diff to fix that error:

    git archive -o update.zip HEAD $(git diff --name-only --diff-filter=d HEAD^..HEAD)
    

    May be git archive is overhead for that task and you should use @eckes's answer.
    But, you still should add --diff-filter=d to exclude removed files from archive.

    0 讨论(0)
  • 2020-12-25 08:59

    I use this alias to include new files not in HEAD:

    alias gittar='tar -czvf working-files.tgz \
                  $(git status -s | sed -r "s/..(.*)/\1 /")'
    
    0 讨论(0)
  • 2020-12-25 09:09

    I'm using this answer in that case that tells me to

    tar czf changed-files.tar.gz `git diff --name-only [diff options]`
    

    For example, to create an archive containing the files changed in the last four revisions, I'd do

    tar czf changed-files.tar.gz `git diff --name-only HEAD~4..`
    

    This assumes – of course – that HEAD~4 does actually exist.

    0 讨论(0)
提交回复
热议问题