What is the proper way of removing a project file from git

During development, I created a .py file and placed it under git control. Over time, I have found that I have programmed around the need for this import and would like to remove it from git control, but would like to keep it in my local copy. For files that are NOT under git control, one can right click on the file in the GUI and under GIT click 'Add', however there is no 'Remove'. I could create a new file with a different name, not place it in git and copy the code over and then delete the original, but I was wondering if there is a more elegant solution.
2 comments
Comment actions Permalink
I don't think PyCharm UI does this, but you can use the git command line to stage the deletion while leaving the local copy of the file:

git rm --cached file

See also: http://stackoverflow.com/a/1273132/858289

Note that when anyone else updates their copy the file will be deleted on their end. Avoiding this is a little trickier: see this.
0
Comment actions Permalink
That does it... I actually want it to be removed from other people's copies, but since the original module required a substantial amount of time to write, I wanted to keep a personal copy in case I find another reason that I would want to use the code.

I was concerned that using the command line to remove it would not be recognized by the GUI, etc. For example that the filename would still appear black or green instead of brown or that the deletion would not be properly pushed to github.

Thanks for your reply!
0

Please sign in to leave a comment.