For a little background, I am trying to use GIT functionality as a way of deploying a website. I have been following this:
To me, in order for it to work, I need to be able to get code out of one Git Repository and transfer it to another that is initialized with "git init --bare". By doing this, webhooks fire and the code is deployed to the correct directory on the server (as seen in the link)
What I have been doing:
I have a Target Repository that has been initialized with: git init --bare
I have an Original Repository - stored in Gitlab - that has a branch named "cons".
I have a job that is supposed to do the following on a regular basis:
- get the contents of the "cons" branch (from the Original Repository)
- push the "cons" branch to the Target Repository
So, essentially, I need to set up a repetitive job that will copy code from the Original Repository to the Target Repository.
To me, the flow would look like:
- initialize Target Repository (get rid of all the files)
- clone the branch "cons" from the Original Repository
- change "cons" branch to "master" branch
- move the "master" branch to the Target Repository
I have tried something like this:
to initialize the remote repository REFERENCE: Delete all files and history from remote Git repo without deleting repo itself
problem: but since this will be running on a regular basis, I felt that there should be a way to do it in one command
create a work directory and "cd' into it
clone the branch git clone -b cons --single-branch git@repos.com:CCLVIN/laravel-work.git
this works but it creates a "repository" with only a branch name of "cons", there is no "master" branch. In order for me to push to the Target Repository, I need to have a master branch.
What can one do to resolve this problem?
TIA