I need to work on file.txt
locally and in Git, with different content. I want Git not to tell me that there have been changes to that file.
Is this possible
All you need is to click the more
button in sourcetree just at the right hand side of the filename, in the unstaged files section. Click ignore
and make source tree perform your desired action for that file or all the files with the same type.
Actually, you want --skip-worktree
, not --assume-unchanged
. Here's a good explanation why.
So git update-index --skip-worktree file.txt
TLDR; --assume-unchanged
is for performance, for files that won't change (like SDKs); --skip-worktree
is for files that exist on remote but that you want to make local (untracked) changes to.
If modifying the .gitignore
file is not an option (because it is checked into git itself), consider using .git/info/exclude
.
SOURCETREE Terminal codes
Add ignore file:
git update-index --skip-worktree index.php
Extract ignore file:
git update-index --no-skip-worktree index.php
List ignore files:
git ls-files . --ignored --exclude-standard --others
Maybe you want to "pretend" that the file hasn't changed when actually it did? You can do that like this:
git update-index --assume-unchanged file.txt
To undo this later:
git update-index --no-assume-unchanged file.txt
To view a list of files that are marked this way:
git ls-files -v | grep '^[a-z]'
UPDATE
As comments have pointed out, this is most probably NOT what you want to do. A better answer has been posted by @Tom Auger, use that instead.
In Eclipse Luna, this can be done [with EGit plugin I think] by doing this: right-click file -> Team -> Advanced -> Assume unchanged