简体   繁体   中英

Amending .gitignore, removing files from git while keeping them locally

All of the developers have files which should have been in .gitignore from the start of the project, but which were not.

Is there a git command to remove files from git, while keeping them locally and keeping them locally on all the other developer machines, when they git pull ?

Ideally this should look at a diff of .gitignore to decide what needs to be removed but kept locally.

At the moment, I am considering the following manual procedure:

My Machine:

  1. get full paths of all files which match the new .gitignore , but which don't match the old .gitignore
  2. add all of those files to an out-of-tree tar file
  3. git rm all those files
  4. commit and push origin master the changes
  5. email the tar file to all the other developers

Every other developer's machine:

  1. git pull which will update .gitignore and remove their local copies of the files which should now be ignored.
  2. untar the tar file over the top of the local repo to reinstate the removed files

This procedure has huge scope for manual errors - is there a better way?

I've looked at:

Remove file from Git without deleting them locally and remotely

Removing a file from versioning but keeping it locally? and

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

Locally you can do this by:

git rm --cached FILE_NAME

Arlo Carreon explains how to do this for multiple developers: http://www.arlocarreon.com/blog/git/untrack-files-in-git-repos-without-deleting-them/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM