Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep my local version of files, without using .gitignore?

Don't want to change .gitignore because other people want the files in the repo. But I have my own copy that I want to use.

I edited .git/info/exclude and added the following:

/Gemfile
/Gemfile.lock
/config/database.yml
/spec/spec_helper.rb

This doesn't seem to do anything. git status still shows:

# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Gemfile
#       modified:   Gemfile.lock
#       modified:   config/database.yml
#       modified:   spec/spec_helper.rb

What is the best way to keep my local versions of files without using .gitignore?

like image 975
B Seven Avatar asked Dec 15 '22 20:12

B Seven


1 Answers

You could probably call git update-index --assume-unchanged [file names] or if there are a bunch of files, just do it to .gitignore and modify the ignore file as much as you'd like.

From documentation (emphasis mine):

When the "assume unchanged" bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. ...
This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files).

like image 116
Roman Avatar answered Jan 13 '23 12:01

Roman