1

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 ?

blue112
  • 52,634
  • 3
  • 45
  • 54
fd80132
  • 41
  • 2
  • 6
  • What's the root problem you're trying to solve? Different configuration for development environments? – bcmcfc Sep 28 '16 at 12:20
  • If you need to not commit a change once then use [`git add -p`](https://git-scm.com/docs/git-add) to interactively select what changes in the file to add to the index. After you add one or more (but not all) changes to the index, `git status` will show the file both in the "Changes to be committed" and "Changed but not updated" sections of its output. However, if you want git permanently ignores some change to a file then you are on the wrong path. Move the things that needs to be ignored in a new file and add the file path to `.gitignore`. – axiac Sep 28 '16 at 12:24
  • You might be able to make [per-branch includes](https://stackoverflow.com/questions/20078756/making-git-retain-different-section-content-between-branches/20087076) work for you, it'd be easier to know if you'd describe the situation you're in that makes you think what you're asking for is the right way to go about it. – jthill Sep 28 '16 at 14:53

1 Answers1

1

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).

blue112
  • 52,634
  • 3
  • 45
  • 54