Remove file from Git without deleting them locally and remotely - wordpress

I have a repository for a Wordpress intall that currently has all the Wordpress files included.
I have updated my .gitignore to only include the theme folder but when I push to my staging server it deletes all the files.
I need to keep all the files both locally and on the server, but I want them to stop being tracked and removed from the repository, Ideally with the history still intact.
Thanks in Advance

The server has a copy of the repository, so if you remove anything from the repository it will be removed from the server's repository as well (after you push).
However, you can set git to assume the files are unchanged. This will keep them in the repository, but git will stop detecting new changes to them.

Related

Problem restoring Wagtail CMS media folder when copying from staging to prod environment

I'm having problems restoring the images for my Wagtail website contained in a media folder. I have two Wagail CMS sites, one development/staging environment and another production environment. The sites are running on AWS inside of Docker containers, and the database is a PostgreSQL database inside RDS. The source code for the site is in GitHub. When I commit a code change, it triggers a new build using AWS' CodeBuild; this creates a new container. I copy over the media folder containing the current images, change the owner/group for the folder, and set the folder's permissions. When I go to the site, the images are missing although I copied over the media folder into the new container instance. The only solution I've found is to manually re-add the images. I wonder if my issue is connected to not executing the "python manage.py collectstatic" command when I create a new container instance. Technically, the media folder contains static files, but I've held off executing the command until I full understand what it does.
Any ideas on how to resolve the images issue?
Images don't only exist as file in the media folder but also in the database through the Image model. Simply having them in the folder isn't enough.
There are currently no mechanism to transfer data between Wagtail instances. There is an RFC and the begining of an implementation but nothing production ready yet.

Git bare repository on remote server

I have a web server with ssh access where I show my customers the preview of their WordPress website. On that Server, I create a git repository for each customer (example: xyz-website.com.git). I run "git init --bare" so I have a repository. Then, I create a hook (post-receive) where I set the git-dir and working-dir. So when I create a Website locally, I can push to that repository and the Website becomes available so the customer can check it.
Problem: When the customer decides to install plugins, there will be new files on the server. My Idea was whenever I need to code something for that website, I just "git pull". Which doesnt work.
Can anyone tell my why and how to solve my problem?
Check whether the wp-content/plugins/ folder is included in your .gitignore file. If it is there, remove it.
For more information, refer this URL: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

Git: How do I pull to a server without bringing the metadata?

I have a staging server I'd like to set up to git pull whenever updates are made to a BitBucket repo. It would be a single repo with multiple submodules, but I can break it apart if that's better.
It'd be a theme that goes to wp-content/themes/
And single/multiple plugins that go to wpp-content/plugins
My question is, (1) is this good practice? and (2) how can I pull the changes without introducing the .git metadata to those (or any public) directory? I assume the metadata has to be somewhere, but how can I hide it?
If this is too vague, please feel free to ask for clarification on something.
Thanks!
Just put the whole thing under git ?
Use .htaccess to disallow the .git folder.
You can use multiple repositories but updating means going to each one and git pull / git fetch git merge.
you could also move the .git directory outside of the web root, make a file called .git with the contents
`gitdir: /path/to/.git`

How to prevent git pull from overwriting a file?

I use Git and GitHub to push changes I make on my local web development environment to my GitHub account and from there I pull these updates to my live production site. I am working with WordPress, so what I have done is .gitignore the wp-config.php file as my productions site has its own unique wp-config.php file with its own respective database credentials. As I am git ignoring this file, when I pull to my production site it gives me the following error:
error: Your local changes to the following files would be overwritten by merge:
wp-config.php
Please, commit your changes or stash them before you can merge.
Aborting
How do I prevent this wp-config.php file from being overwritten (more specifically deleted) when I do a git pull?
This is your machine specific config file. For such case its better to use build tool. For you its better to create your custom configuration on a special file my-config.php and include it in wp-config.php. Also ignore my-config.php in .gitignore. Now you'll never see any problem like this.
What you will see is my-config.php file not found error. And write it about in your README.
I do this whole thing with configure, make even the project is in php
If this was not a config file, and you are sure about the changes you can commit first and then execute pull. Other option is stash which is already told in the error message.
Your changes won't be overwritten. That's what the error message is telling you. The pull failed because git doesn't want to overwrite your changes.
To allow the pull to take place and keep your changes, do git stash before pulling. This will save a copy of your changes and allow you to pull without any issue. Then git stash pop after pulling will restore your changes. Note that you may experience a merge conflict if the changes you are pulling to wp-config.php touch the same part of the file as your local changes.
The other side doesn't have the ignore file in effect yet. Once it's there, you won't have this message. Also it's still tracked. So in addition to changing the .ignore file on both sides, you also need to delete it on both sides and from then on it will not get in the way.
Also take a look at octopress if you are going to be using git as part of your blogging routine.

How do I configure git to create files with the right permissions?

I have a git repo that includes submodules for wordpress and a wordpress theme. I am trying to configure this so that I can run "git pull" on the server whenever there is a change, to update the files from the repo. The problem I am having is that after I do a git pull, I end up with a 500 error on the front end and my server logs saying "file is writeable by group". Basically, I need all of the files to have the permissions of "0755" and to stay that way after I update them with git. How can I set this up correctly?
Check out the documentation on filemode. In your repository under .git/, the config file has a section starting with [core]. If you set filemode to FALSE (or zero, I can't quite recall), it will stop git from changing permissions on any of the files. Then, you can just update them to the right permission and leave them alone.
Note that you could run into other permissions errors if you are having git run as a separate user (we do this with a git user who runs automated updates). Just something to be aware of as you set things up.

Resources