So I'm programming using the CodeIgniter framework. I was wondering the best way to go about deployment to the live server.
My question stems from the default .gitignore.
If I add and commit the files to my Git Repo (which I will then use to pull from and then into my live web server on Cloudways), the problem is that not all the files will be added in the git repo, and thus not all files will be copied over to the web server on Cloudways. What's the proper mechanism to copy all the files to the live server?
Do I delete .gitignore, and then commit ALL the files into the remote repository, so that Cloudways can pull all the files initially? And then copy the .gitignore file back into my local machine and then add and commit through there so that the unnecessary files won't go through and will be ignored in future git commits?
I'm so confused. Before I would bypass Git, and just edit the files live on the website. But now I feel like I need to go the proper route and use Git repositories for my future projects.
Also, what's the proper way to develop locally and then pushing files to the live server? Wouldn't I have to keep changing the database and config files before each commit/push from my localhost configuration to the live server's configuration? I'm so confused, please help lmao...
Git is a version control tool, not a deployment tool. People invented work-arounds and frameworks around though to use Git for deployment, but it is not one of the Git features per-se.
You can add files that are in
.gitignore
simply by usinggit add -f ...
, but this is most probably not what you want. Also.gitignore
is only affecting untracked files. As soon as you added a file to Git, its changes will be tracked, no matter if it is in.gitignore
or not.If files are in
.gitignore
you certainly had a reason to put them there, like being config files that need to be different on the live server and in your local environment. Just create those files on the live server with the corresponding settings manually.