1

This question is related to this previous question.

These two files below are under version control which causes some inconvenience in magit-status:

Unstaged changes (2)
modified   .emacs.d/projectile-bookmarks.eld
modified   .emacs.d/transient/history.el

This is my .gitignore file:

transient
projectile-bookmarks.eld
.emacs.d/projectile-bookmarks.eld
.emacs.d/transient/history.el

The file location is: .dotfiles/.gitignore. I thought my gitignorefile would solve this.

Did I miss something? How can I fix this?

I want to remove these files from being under version control. It is necessary to keep them in my machine, apparently - since the emacs package depends on it to properly work.

4
  • 2
    This is not a magit issue but a git issue stackoverflow.com/questions/45400361/…. I dont know if any of the answers there is upto the mark. I recommend rtyley.github.io/bfg-repo-cleaner
    – Rusi
    Apr 27 at 15:21
  • 1
    I don't understand what you want to do here. You have files under version control, but you want them to be hidden when listing unstaged changes? I doubt Magit has this functionality. It would be confusing to not see unstaged changes if all the changed files are hidden, but those unstaged files would still prevent operations like rebasing that require a clean working directory. Apr 27 at 16:03
  • 1
    Or do you want those files not to be under version control? If so, you need to remove them. .gitignore only prevents files from being added when adding a directory, or listed as unchanged when they aren't committed. It has no effect on files that are already committed. Apr 27 at 16:03
  • @Gilles'SO-stopbeingevil', thanks for trying to help! I want to remove these files from being under version control. It is necessary to keep them in my machine, apparently - since the emacs package depends on it to properly work. Apr 27 at 19:46

1 Answer 1

3

.gitignore is only relevant for files that are not already tracked by Git. If you've started tracking a file and now regret it, you need to remove it from Git. Once that's done, if the file is listed in .gitignore, Git will no longer propose to add it (but you can still add it by explicit request).

To remove a file from Git without removing it from your working directory, you can use magit-file-untrack (K from the Magit buffer). Then commit the change that removes the file.

1
  • This solved the problem, thank you! Apr 29 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.