source tree marks all file as modified - php

I started using sourceTree
I have a problem when I change certain files, I noticed those are files from my views folder (MVC), sourceTree marks it as:
Modified file, 1 lines changed, 1 lines removed
and when I push it to my svn the whole file is marked as changed, as in:
All the code from before my changes marked with '-'
And then all the code from after my changes marked with '+' (also stuff I didnt touch)
Any solutions?

Make sure that the config core.autocrlf is set to false, to avoid automatic eol (end of lines) conversion on all your files.
git config --global core.autocrlf false
(and re-clone your repo to see if the issue persists)
See for more "SourceTree App says uncommitted changes even for newly-cloned repository - what could be wrong?"
This sourceTree thread points out also to .gitattributes files.
The OP Asaf Maoz points to another source (in the comments), still related to eol:
the problem was in my IDE line endings settings, some files line endings was set to MAC (when I am not on MAC) and ST could not convert them properly.

Related

Corrupted php.ini (wordpress)

I have been working on a Wordpress site that hasn't had any updates in many years and preparing it for a theme change as well.
After updating all plugins/Wordpress 5.2/PHP 7.2 everything seemed to be going well however the site has been experiencing intermittent crashing (it will work for awhile then it will crash for 5-10 minutes) [edit: The site crashing was probably not directly caused by the php.ini issue in retrospect]
Looking at the cpanel in the error logs I get the error:
PHP: syntax error, unexpected TC_LABEL, expecting '=' in /home/website/public_html/php.ini on line 1 //sometimes it includes a referer
Running php -i | grep php.ini:
Configuration File (php.ini) Path => /opt/imh/imh-php72/root/usr/lib/php
Loaded Configuration File => /opt/imh/imh-php72/root/usr/lib/php/php.ini
The php.ini (in public_html) contains the same repeated path many times (78,886 times according to my find and replace):
/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718
Line 1:
/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718[/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718P/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718H/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718P/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718]/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718
I noticed that there was sometimes an extra character after 20170718. I downloaded a local copy and did a find and replace and removed all instances of the path and what was left is a 'normal' php.ini (ie it's as if every character in the file was replaced with path + character)
[edit: Changing the public_html php.ini to php.ini_bk removes the error from cpanel logs]
Personal PS: Please note I am not a PHP nor Wordpress developer (typically I work in the MERN stack)
public_html is not the right place for php.ini
Can you do a
php -i | grep php.ini
You have several options ... make a backup of your "old" php.ini first
rebuild your PHP configuration
download latest PHP
Download PHP source and just copy php.ini template out of that
Sometimes it is better to do a clean install & import than updating a very old WordPress.
Regards Tom

Wordpress files modified durning git clone (line endings, filemode or gitattributes did not help)

I'm aware certain changes may occur when cloning a repo from one OS to a different OS. However, this is not just newlines added or space formatting (but that is also happening). Chunks of code have been removed and modified completely.
I see newly added blocks, functions, .esc_attr and .esc_html tags.
I've played with .gitattributes files, set different core.autocrlf values and core.filemode values - nothing worked.
Also strange that only a subset of php files were modified. All located under Ultimate_VC_Addons.
git status image
git diff image
Any help is appreciated.
Thank you.

Git: Cannot remove .php~ files

I use Git on a Symfony 2 project. I would like to switch branches, but I get the following message:
These untracked working tree files would be overwritten by checkout.
Please move or remove them before you can checkout.
Here a list of the files:
srv/myproject/src/mycompany/mybundle/Entity/Contacts.php~
srv/myproject/src/mycompany/mybundle/Entity/Products.php~
srv/myproject/src/mycompany/mybundle/Entity/Orders.php~
What I tried so far:
For example, I tried to do
git rm --cached srv/myproject/src/mycompany/mybundle/Entity/Contacts.php~
which gives me the message that the file does not exist.
I cannot find any "php~" files in the "Entity"-Folder. I can only see the regular "php" files.
Why do these files have the char "~" at the end of the file name?
How do I solve this problem?
Files with names ending with ~ are typically backup files made by some editors. Whether they are made by your editor, I have no idea.
They are shown as untracked (Git says these untracked working tree files...), which means they are not in the index, so you cannot give them to git rm --cached which just removes things from the index. This in turn means that—at least at this point—you have done nothing wrong. :-) Which might be reassuring, but is not really helpful.
Nonetheless, git checkout <otherbranch> is complaining that the proposed checkout would overwrite them. This means that they are contained in the commit that this git checkout would check out. That, in turn, means that someone, at some point, did something wrong, by committing them in the first place. (Assuming, at least, that they are just editor backup files that should not be versioned like this.) That could be someone other than you, meaning you have done nothing wrong, but, well, still not helpful.
This also means that they are in your work-tree right now. How they got there is hard to say, though the most obvious candidate reason is that your editor made them as editor backup files.
What you need to do
What you need to do is to move or remove these files (assuming they're editor backups, it is likely safe to just remove them entirely) so that they are no longer in your work-tree. Then git checkout will be able to put the ones from the commit into your work-tree, without clobbering the ones you already have, since you no longer have them.
What else you and/or others need to do
Committing these files is a bad idea (assuming, as always, that these are editor backups). It's kind of hard to fix this in existing commits. It's up to you and your co-workers / colleages whether to bother. However, one way or another, future commits should not contain these files.
To that end, you, or someone, must not only remove them now, you must also check out the commit(s) that have them, then remove them (e.g., git rm *~), then either fix those commits or make new commits that tell Git "they were there, and they will be in commit history, but from that commit to this new one, remove them now."
Moreover, you, or someone, should probably set things up so that Git ignores these files by default, so that it will not put them into future commits. The usual method is to add a line *~ to the top level .gitignore file. (However, once files are tracked, adding them to .gitignore has no effect until they become un-tracked by an explicit remove. This is because .gitignore is the wrong name: it's not a list of files to ignore, it's a list of files to not add, and to not complain about forgetting to add.)
remove unwanted files from git:
git reset HEAD path/to/unwanted_file
create .gitignore file and add *~ to it.
do a new commit.

How can I use Git with different database configurations between developers?

I am developing an application in Code Igniter with a friend. Because both of us have different database logins on our machines, we have different "config/database.php" files.
How can I tell Git that both of us have different database configurations? Right now, we are getting merge conflicts every time we pull because "config/database.php" differs for us.
I usually rename the /application/config/database.php file to /application/config/database.default.php (versioned) and add the original path to the .gitignore file. Then, each developer copies the default (unversioned file) back to the original path and edits per their local settings.
This becomes an extra step in the server setup process, but it saves the grief you mention.
Have a single file that selects config based on an environmental variable. Set that variable in your server's config.
<?php
if (getenv('WHOS_CONFIG') == 'mine') { … } else { … }
and in server config (which you wouldn't verison, otherwise same problem arises again :)
e.g. for Apache:
<VirtualHost *>
SetEnv WHOS_CONFIG mine
…
Alternatively, have a common database.php config file that includes database.local.php file that is not versioned. The latter would override variables you need.
Two options are:
Don't version control this file anymore (I leave git-command to your research)
Use the .gitignore file
As result you'll have file on old place, butit will not interfere with "another" file anymore
We usually put database configuration files in the .gitignore file to avoid these issues. It's a good idea anyway not to put these config files with their user/passwords in git.
We'll frequently keep a config/database.yml.template file (we're using rails) as the basis for folks to copy to config/database.yml and then edit to their local machine. The database.yml filename is put in the .gitignore file (which is shared under version control).
Basics on gitignore can be seen here.
Additional info, including pitfalls to avoid at: Ignore files that have already been committed to a Git repository

Replacing Notepad++ for Vim (I use PHP). What do I have to know?

I was using Notepad++ under Windows for a long time. But I'm having too many troubles with the configuration. It suddenly changes my indentation config every now and then. So I decided to change my editor to Vim. As you may guess, it's a big change :P so I'd like to know what do I need to have in mind knowing I develop in PHP. I'd like to use everytime UTF-8 without BOM, even if the original file is not using this encoding. By now I've figured out this in my _vimrc (BTW, is this the right place to do it?):
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set number
setglobal nobomb
setglobal fileencodings=utf-8,usc-bom,latin1
setglobal encoding=utf-8
Do I have to config these options in the file _vimrc so everytime I open Vim it takes into account these configurations? what other configs should I use? I want 4 spaces instead of tabs and I've found that the first 4 options do that.
On Microsoft Windows systems, the _vimrc file is the correct place to put configuration items that you want to apply to all runs of vim. On Linux / Unix systems, the file is named .vimrc.
If you want a setting, you can always type : and then the configuration command. The vimrc file basically runs those commands prior to the start of your editing session.
Since the file exists between sessions, and it is read by default each time you run vim, you do not need to configure these options every time you run vim. If you want to change your settings, editing the vimrc file will preserve the changes for all future launches of vim.
set expandtab automatically replaces tabs with spaces.
set tabstop=4 indicates that a tab is equivalent in width to four spaces.
set smartindent indicates that you want vim's file detection routines to indent as you type based on the rules encoded in the file type specification. This means that for .c files, information within braces will be indented automatically under most normal typing circumstances (editing afterwards can undo the automatically added characters).
set shiftwidth=4 indicates that the code indention >> or << controls should indent four spaces.
Note that it is possible to embed vim settings into comment sections of some files. In such a case, the embedded settings will apply to the file being edited, and not have an impact outside of that file. In vi, type :h modeline for details.

Categories