Cloning a Git Repo Into a Non-Empty Directory
I have a WordPress plugin deployed to a site via zip installation and want to replace the code in the plugin directory with the versioned code from the repository and/or change the branch on the server.
SSH into the server and change directory to the plugin.
Create a temporary directory:
mkdir temp
Clone the code into the temporary directory using https protocol which will prompt for a username and password (a personal access token needs to be pre-configured):
git clone <repository-https-URL> temp
Move the .git folder to the target directory:
mv temp/.git ./
Remove the temporary directory:
rm -rf temp
Check out the repository files:
git checkout .
Feedback?
Email us at enquiries@kinsa.cc.