Let’s pretend I have a project directory that isn’t a git repository. This project is open source, and it is listed on github. I’d like to update my project directory to the latest repository structure. I could do this by copying the repo’s .git/ to my directory, followed by a
git reset --hard
Which would then change the preexisting working directory to match the github repository. Normally, I’d just start fresh by cloning the github repo, but in this case may I have deployment-specific files I’d like keep(which are listed in .gitignore).
I wonder, is there an better way to do this besides manually copying the git index to non-git directory?
A common way to do this is to have a script that does the following:
People often use this in a
post-receivehook in a bare repository, so that you can deploy a new version of the application just by pushing to that repository.