Excluding files from

I recently switched from svn

to git

.

After unsuccessful thorough disassembly with google and its searchers, please find my situation as below:

Scenario

I added files in .gitignore

to make git status

silent information about unaffected files.

Problem

The problem is that every time I rebase

my branch this file gets overwritten as well and I see all non-playable files on the console.

Demand

Is there a way to make it git ignore <.gitignore_file>

so that this file gets excluded due to being reloaded / overwritten in any operation?

+3


source to share


2 answers


If you commit the file .gitignore

, I don't understand why you must have this problem. But nothing prevents you from adding .gitignore

to.gitignore



For an alternative way to exclude files, you can create a file .git/info/exclude

that acts as a local file .gitignore

outside the working directory.

+3


source


You can define a custom merge driver that will only apply to .gitignore and always keep the local version.
See " Git: How can I rebase many branches (with the same base commit) at once? " For a specific example.

This driver merge " keepMine

" can be linked to .gitignore

and declared in a file .gitattributes

present in each of your branches.
See " How do I tell git to always choose the local version for conflicting merges on a specific file? "

echo .gitignore merge=keepMine > .gitattributes
git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"

      



With, keepMine.sh

put it somewhere in yours $PATH

, not in the repository:

# I want to keep MY version when there is a conflict
# Nothing to do: %A (the second parameter) already contains my version
# Just indicate the merge has been successfully "resolved" with the exit status
exit 0

      

(For a, KeepTheir.sh

see " How to Stop a Merge (Again ...) ")

+3


source







All Articles