What rules should i add to .gitignore to ignore all error_log.txt files generated in php?
I have tried adding simply error_log to it, but it doesn't seem to work.
Im working on a Win7 x64 and i am new to Git.
To ignore a file (like error_log.txt) in all directories of your repository, you should add the following rule to the .gitignore in the root folder of your repo:
error_log.txt
As said, that will ignore all files called error_log.txt in all directories and subdirectories of the repo.
Be aware, that .gitignore does only ignore files that are not tracked yet. If you have added and commited a error_log.txt already, that file will stay tracked. See Ignore files that have already been committed to a Git repository for futher detail on that.
Related
I am using git and PhpStorm for my project. When i trying to push, or pull, or to do any else action, i also see git repositories from /vendor (composer).
How to disable they for PhpStorm?
UPDATE:
/vendor already in .gitignore
# composer vendor dir
/vendor
In the root of your project just create/edit the .gitignore file and add the following
/vendor
You can do this for any directory you would like
if you want to include a sub-directory of a directory you exclude just add something like this.
!/vendor/bin
Here are the relevant git docs about it:
https://git-scm.com/docs/gitignore
Edit: I saw you did indeed have a correct .gitignore [assumption based on your reaction to the comment] If you have already worked with a file in phpstorm and added it to the ignore pattern later phpstorm does nothing with it, you should be manually removing the folder from your machine and from the repo [by deleting and commiting/pushing].
Just delete it and commit it to origin. and just use composer to reinstall. voila!
I find the solution! It was in File->Settings->Version Control. I Just unregister vendor roots. Thank all for help!
Do not know if very correctly applicable, but my search leading to this question was solved by applying "git reset" command on files I added prior adding them to a .gitignore file.
I have a Symfony 3 project.
In the root dir is the usual vendor dir that composer uses for installation.
In the web dir I also have a vendor dir for bootstrap, fontawesome etc.
In .gitignore I have an entry vendor.
Unfortunately both vendor dirs are ignored. But I want to commit the web/vendor dir.
How is that possible?
May be I have found a solution. I added !web/vendor to the .gitignore.
Is this the right way?
gitignore will recursively ignore everything that matches the "vendor" pattern if that is all you have in your gitnore.
There are some basic rules about gitignore you should familiarize yourself with.
The one here is that gitignore will run relative to the directory it's in.
So, if you add a /vendor entry to the .gitignore in your root dir, then it will only ignore the vendor directory in your root dir. Leave out the slash, and it will drill down as far as it can go and ignore everything that has a vendor in the name, whether it be a file, directory, whatever.
A tip: try looking up sample .gitignore files on github for a specific project type you're using. These are usually good enough to get going.
For symfony, a good one is here: https://github.com/github/gitignore/blob/master/Symfony.gitignore
Yes, that was the right way. Just add !web/vendor.
I am migrating from shared web hosting to Heroku and can't figure out how to user Composer properly.
I have my app pointing to public_html folder, with the composer.json file in the root folder above this. This would generate a vendor folder in the root folder, which (for reasons I don't understand) I was unable to access when I tried including the autoload.php file in my code (e.g. require_once('../vendor/autoload.php')).
My solution to this was to move composer.json into public_html, but that caused no end of problems with Heroku not finding it, so I moved it back. I then changed the vendor directory in composer.json to point to public_html/vendor.
This had the desired effect, except now my app won't run because it can't find PHP, presumably something to do with the new location of vendor.
Is there a way to either:
Configure composer.json to have Heroku put everything except PHP in public_html/vendor, and put PHP into a root vendor directory, or
Access files above public_html from within my code to allow me to include autoload.php?
OK, it turns out it was a relatively simple fix that I just figured out myself. I'll post it here in case anybody else happens to make the same mistake.
If you change vendor-dir in composer.json, you also need to change the Procfile from
web: vendor/bin/heroku-php-apache2 public_html/
to
web: public_html/vendor/bin/heroku-php-apache2 public_html/
I've never used Composer before, but installed it so I could set twig up the recommended way.
I now have composer.json and composer.lock files in two separate directories. How do I determine where they SHOULD be? I assume they certainly shouldn't be in my public html root, as one of them has managed to be?
The composer.json file should be created at the topmost directory of your project, i.e. the top directory that is in version control. Subdirectories of this directory likely are for example the "public" or "htdocs" or "www" directory which is the document root for the web server.
By using Composer, this directory will also get a "vendor" directory where the packages are being placed, as well as the composer.lock file which records the exact versions being installed.
Do commit both composer.json and composer.lock. Don't commit the vendor folder, put it onto the ignore list.
I want to move a git repository to a sub-directory which is there in its present root folder.
Let me explain the things first.
I have Git repository testing in $HOME/repos/ (contains PHP code-base).
Now i want to move testing into $HOME/repos/php/ where php will be sub-directory which i want to create (anyway php directory is not a git repository)
My questions are
if i do above explained move then does this effect my testing repository ?
Does this effect any branches or commits or uncommitted changes in testing repository ?
Moving a repository to a different directory should have no effect on the repository. Simply move everything as you would with any other kind of files, taking care to move the .git directory along with it. That .git directory is what git looks at and compares against other stuff in the project directory (wherever that .git directory lives).