I have a repository working on git. There is a file called config.php inside a directory called site_configuration. What i want is that when someone clones the repository it should download the default configuration file, and then if someone changes and pushes the new code, it should be ignored and shouldn't be pushed to the server.
Currently in my gitignore i have this, but for some reason it still tracks the file and pushes it to the repository.
site_configuration/config.php
You can't force Git to ignore changes to a tracked file (as, in your case, the site_configuration/config.php file) in a safe way. If you want the file to be ignored, you need:
Keep the .gitignore file as you have defined
Rename the site_configuration/config.php file to site_configuration/config.php_sample
Tell everybody to copy config.php_sample to config.php. Maybe you could have some automation for that.
Related
My SVN repository contains multiple projects. Each project contains the same structure that looks like trunk -> doc -> log.txt. This log file contains the changes made between revisions.
Currently I created a php script that executes when a server build is run. This php script checks out log.txt file on the server's local directory. C://..../..../doc/log.txt.
It writes into this file and then commits the changes. The problem occurs when someone runs the server build with another project. It tried to check out the log.txt file of that project into the same directory and I get an svn error. I no longer need the checked out files in the local directory once the changes have been committed. The only option I could think of is to delete the doc folder (only in my local directory not the repo) before checking out the new one so that the previous log.txt is no longer there.
I found a recursive algorithmthat deletes all files with unlink() and directories with rmdir. The algorithm works well. Unfortunately, the hidden .svn files do not unlink() with permission denied errors. Using fileperms() on all files and parent directories gives back 16895 which translates to 40777 in octal, so I believe they have full permissions. But I believe permissions for users do not have modify/write. Is there a proper way to delete the hidden .svn folder on my server's working copy? Alternatively if anyone can think of a better method to do this. So if AprojA/doc/log.txt is already in the local directory and I check out BprojB/doc/log.txt. Is there a way to checkout and overwrite the existing log.txt with the log file from another project? --force parameter doesn't seem to do much for me.
I also had a vague idea of maybe checking out the top level svn repo with -depth=empty. and then svn update just the log txt files of each project. So instead of checkingout -> committing changes -> deleting. I can just have all log.txt files available. But the problem is they all have the same folder and file name of (doc/log.txt). Still relatively new to all this so I'd appreciate feedback of any kind.
u can use wild cards to delete the log files with the extension. so all files of the same extension will be deleted under the selected folder.
I AM USING VCS SOFTWARE FOR GIT.
I added a file : "Somefile" and then committed onto the server.
But following files also gets commited :
The file names that gets added to git
I checked the files added , before committing and it shows only 1 file.
I have also unticked the checkbox for any other files.
Still how does these files gets added and
how to solve this ?
It works fine when i do commit with git terminal.
These files exist in : /php/htdocs/inc/js/tiny_mce/plugins/ibrowser/scripts/phpthumb/cache
Make a .gitignore file and add
*.JPE
This will ignore any file ending in .JPE
I think, you no need to put cache files to your git remote repository.
So, the best solution to fix this issue - put cache files under git ignore.
Create .gitignore file in root directory if this file doesn't exist yet.
Add directory, which you want to ignore in .gitignore file:
/php/htdocs/inc/js/tiny_mce/plugins/ibrowser/scripts/phpthumb/cache/*.JPE
Good luck.
My GIT repository is located /var/repo/myRepo.git. I set a GIT hook post-receive* to copy the files from my repository to the folder of my project
git --work-tree=/var/www/laravel --git-dir=/var/repo/myRepo.git checkout -f
Each time I commit and push something on the server, the file var/www/laravel/config/services.php is replaced and the modification I did on the server is replaced by my local copy.
For instance, if I manually modify the following file like this on the server (by ssh session)
var/www/laravel/config/services.php
This is the modified content of this file
It will be like that after a commit and push
var/www/laravel/config/services.php
This is the default content of this file
I tried to add /config/services.php to my .gitignore but it does not seem to work.
.gitignore
/node_modules
/public/storage
/public/hot
/storage/*.key
/vendor
/.idea
Homestead.json
Homestead.yaml
.env
/config/services.php
What should I do so this file is not replaced each time I commit something on my server ?
What should I do so this file is not replaced each time I commit something on my server?
You have only two options:
don't check it in, or
don't check it out.
Your git checkout -f command means "get me the latest commit, overwriting everything." If the latest commit has a new version of a file, that overwrites the old version of the file.
(Moreover, a .gitignore file does not mean what you think it means. It's not a list of files to ignore. It's a list of files—or name patterns—not to complain about. Usually most important, it lets you declare to Git: "Yes, I know these are in my work-tree and not in my index; don't tell me that." That's on the input side—i.e., the "don't check it in" part.)
This leads to a general rule about configurable software, where the software itself is maintained in Git, or indeed any version control system: Do not put the configuration into the version control system. The configuration is not part of the software.
Consider Git itself, for instance. You must configure Git to tell it your user.name and user.email in order to make commits with your user-name and email address. Now imagine Git came with its configuration file built into the software, that said your user name is Fred and your email is fred#fred.fred. Every time you updated Git to a new version, it would change your name back to "Fred <fred#fred.fred>". That's not very friendly, is it?
Git stores your configuration outside of the Git software. There are, to be sure, default configuration entries, but anything you set, is kept elsewhere. Updating Git does not touch this. This is not specific to Git, or even version-control systems: any system that provides upgrades must not store its configuration in a file that is destroyed by the upgrade.
So, stop doing that.
I did git rm /config/services.php and reimported the file manually. Now the file is not replaced by GIT.
I have MAMP setup on my mac, and I have a web app installed in the htdocs folder that use my mysql databases. So far everything is working great. The problem is the project is using git, so I installed the github mac app. Theres a .gitignore file that includes a bunch of files, but I'll just list one to explain my problem. This file is in in .gitignore:
/application/config/development/database.php
But, when I make changes to it, it displays in my change list. Using the github mac app, I right click and choose ignore, and it inserts this path into my .gitignore file:
application/config/development/database.php
Notice the missing '/'. But then, .gitignore shows up in my uncommitted files, and the database.php file is not ignored! Also, .gitgnore is in the .gitignore file as well. Is this a relative path problem? A git installation problem? Halp!
Usually .gitignore is commited (and pushed) like any other project relevant file. When it shows up under changed (but not staged) files, it is ok. You should commit and push it.
The fact that.gitignore contains itself makes absolutely not sense, I would recommend to remove this line.
The paths in .gitignore are relative to its location. When .gitignore is in /home/foo/bar then /herp/derp.php in .gitignore means
/home/foo/bar/herp/derp.php
whereas herp/derp.php in .gitignore will match
/home/foo/bar/herp/derp.php
as well as
/home/foo/bar/baz/herp/derp.php
The fact that the database.php shows up under changed/uncommited files means quite sure, that this file previously has been commited. You will havt to remove it from the working tree:
$ git rm /application/config/development/database.php
and commit the changes along with the changes in .gitignore.
Hope this helps!
I have a project in NetBeans which haven't used CVS until now. Let's say the directory with source files is called /www/source_files and directory with project files /www/project_files. Module in repository is called differently than source files directory. When I'm trying to check out CVS, it forces me to create a directory called exactly how module is called, which is fine by me in fact. Straight after it asks me if I wanted to create new project. And here the problem begins. I don't want to do that and I have no idea how to link newly created directory with CVS and checked out files with my project.
I'd like to end up with following structure:
/www
/source_files
/project_files
/cvs_files
Any ideas how to do this? I'm using NetBeans 6.8.
Ok, I'm going to answer my own question here. I found something different, but it basically does the same as I wanted.
I checked out CVS module into /www/source_cvs, as I did before. Then it asked me once again if I wanted to create new project. This time I said yes and made a project in checked out directory. But I also checked "Copy files from Sources Folder to another location" and set it to /www/source_files.
So in the end, I'm working all the time in directory which has CVS files in it, but it always copies whole content of this directory to another clean one.