fd80132
fd80132

Reputation: 41

git Ignoring only some changes in a file

In fact I would like to know if it's possible to ignore a change once, but not the others..

For example I have a file "file1", first I write some change into the file, for example I add "hello" to the last line. Then I want someting to ignore this changement in a git status, but keeping the "hello" line to the file, and for each other change I want to see in " git status " that the file is changed.

So --skip-worktree for example don't work, because it ignore my changes and keep the new lines, but it also ignore my futures change into the file..

Is it possible to do that ?

Upvotes: 1

Views: 42

Answers (1)

blue112
blue112

Reputation: 56482

As far as I know, what you're exactly is not supported by git.

Git doesn't really know what a "change" is to you. If you add something else to do the same line, it is the same change? To the next line? To another part of the file?

I would recommand to put that change in a separated uncommited file, that could be somehow included into the wanted file (using a language paradigm or a build mechanism).

Upvotes: 1

Related Questions