Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Config files are already in remote git repository. Want to unversion but not delete. How?

My friend and I have elected to use git and GitHub to collaborate on a project. We are both very new to it.

My friend made an initial commit of our project files with his version of the project's config files included in it. My config files will be different. We do not want to send changes to these files back and forth.

I have already issued git init and git pull [email protected]:my_friend/our_repository.git master to get our project files onto my development server.

I then created a .gitignore file in the project root on my dev server (where I did git init):

# this is .gitignore in the project's root directory
index.php
config/some_config_file.php
config/another_config_file.php

Since these config files are already in the repository, these lines in .gitignore aren't going to do anything. I understand this. Other SO answers have suggested these commands:

git rm --cached index.php
git rm --cached config/some_config_file.php
git rm --cached config/another_config_file.php
git commit -m "hope this works"
git push 

but this deleted these files in the remote GitHub repository! Not good. I want these files to remain on GitHub so it doesn't alarm my friend. I just want to keep my own unversioned copies of the files on my dev server, independent of whatever is going on in the GitHub repository.

How can I achieve this setup with git?

like image 527
markplindsay Avatar asked Feb 23 '23 08:02

markplindsay


1 Answers

You cannot do that, but you could tell git to ignore further (local) changes to those files. Try:

git update-index --assume-unchanged <your_file>
like image 149
jweyrich Avatar answered Feb 26 '23 06:02

jweyrich