Specifically, I maintain a git repository of my dotfiles. I recently started working on a new machine and cloned my repository on the same.
Now, I wish to make some changes to my dotfiles which are specific to this system only. These changes I wish to ignore in my repository.
Other changes that I make, should continue to be tracked and committed.
For example, in my .gitconfig, I have a setting as:
[push] default = simple
Now, on my new machine, the version of git being used it very old. It still not not support the setting simple
for push. So, I'd like to change this, but only locally.
However, if I make any other changes to my .gitconfig, I'd like to keep track of those. Anyway I can achieve this?
EDIT:
I know of git update-index --assume-unchanged
. The problem with it is that git will no longer track my file at all, until I reverse it. And then, it will track all changes.
I wish to ignore certain changes and track the rest.
If you want to ignore certain files in a repository locally and not make the file part of any repository, edit . git/info/exclude inside your repository.
In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.
Simply move the files to a folder outside of git, then do "git add .", "git commit". (This removed the files) then add the gitignore, referencing the files/folders, commit again to add the gitignore file to git, then copy/move back in the folders, and they should be ignored.
What you probably want to do is this: git update-index --skip-worktree . (The third option, which you probably don't want is: git rm --cached .
Try using this command:
git update-index --assume-unchanged FILENAME_TO_IGNORE
To reverse it (if you ever want to commit changes to it), use:
git update-index --no-assume-unchanged
UPDATE:
Here's how to list 'assume unchanged' files under current directory:
git ls-files -v | grep -E "^[a-z]"
As the -v
option will use lowercase letters for 'assume unchanged' files.
I don't believe there's a specific command that will 'untrack' certain changes to a file. However, there's no reason that you couldn't create a local branch into which you pull changes from your remotes, but never send any changes back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With