Search code examples
gitdeploymentproduction-environmentgit-deploy

How to remove the entire git trail in a production environment after deploying code


It is strange to me that I have not found anything related to this situation, which in turn seems very usual...:

I have finished a web project for one of my clients, and they have provided me with access to one of their remote production machines in order to deploy the code. There, I have done git clone and I have successfully deployed it. Now, I want to remove all the git trail because when I execute, e.g., git status, it returns the same output as in my local development environment. In others words, I would like to leave the code there, but not any git files, configurations, or tracking information about my repo.

What is the professional way of doing a production deployment using git, but leaving only the code? Thanks in advance.


Solution

  • You can copy the clone then remove the .git directory.

    Better way to do it is use git archive then extract it to your production area.

    git archive <TAG> --output=production.tar
    

    You can also specify a zip format. *--format is option. It tried to guess the format from the file name. See git archive --help

    git archive <TAG> --format=zip --output=production.zip