Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. There are times notifications aren't wanted about either a changed repo file or a new file that needs to be added to the repo. However, adding the name of the file to `.gitignore` might not be a good option, either.
  2.  
  3. In those cases, use one of these solutions:
  4.  
  5. 0. **If the file is a changed repo file**
  6.  
  7. Use the command:
  8.  
  9. `git update-index --assume-unchanged "$FILE"`
  10.  
  11. To undo this, use the command:
  12.  
  13. `git update-index --no-assume-unchanged "$FILE"`
  14.  
  15. The `update-index` command doesn't work with new files that haven't been added to the repo yet, though.
  16.  
  17. 0. **If the file is new and not added to the repo**
  18.  
  19. Add its filename to the repo's `exclude` file:
  20.  
  21. `echo "$FILE" >> .git/info/exclude`
  22.  
  23. This also works for changed repo files, but there isn't a specific undo command for it. The `exclude` file would need to be edited and the filename deleted from it. Or other commands could approximate it:
  24.  
  25. `grep -v "^${FILE}\$" .git/info/exclude > tmp.$$ && mv tmp.$$ .git/info/exclude`
  26.  
  27. Note that this overwrites the existing `exclude` file and if the filename specified contains special characters that could affect the regular expression, the results are unpredictable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement