3

I have a GIT repository where there is a dist folder which is required for some build/deploy job. On my local there is a chance of content change in that dist folder due to grunt build or something. But I don't want to commit those changes, so I want all the changes to be ignored/untracked in that directory (dist).

I have found this article and tried git rm -r --cached <your directory>. But when I do git status after the above command it shows all the files have been deleted and dist folder has been untracked. So, if I commit this, then all the files will be deleted from central GIT repo also and I don't want that. I want GITHUB's dist folder to be untouched. Is there anything by which I can achieve this?

Upadte 1: I have tried including in the .git/info/exclude file but still it did not work.

exclude file

I have changed a file inside dist but still it's showing in git status

file inside dist folder

Community
  • 1
  • 1
Debajit Majumder
  • 824
  • 1
  • 11
  • 22

1 Answers1

2

You can add dist/ line to your local .git/info/exclude.

From documentation:

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.


For already existed files try:

git update-index --assume-unchanged <file>

and then when you want to track changes again:

git update-index --no-assume-unchanged <file>

dizballanze
  • 1,267
  • 8
  • 18
  • Please see my update in the question. It did not work or am I missing something! – Debajit Majumder May 24 '16 at 16:47
  • @DebajitMajumder seems that exclude method works only for new files, I have updated the response. – dizballanze May 24 '16 at 17:09
  • Yes this works but for **single file**. I have many sub-folders inside `dist` and all together there would be around 100 files inside `dist`. So, it's not really feasible to do it for each and every file. If you could suggest anything for the whole directory/folder? – Debajit Majumder May 24 '16 at 17:22
  • In bash you can use something like this: `git ls-files | xargs -n 100 git update-index --assume-unchanged` – dizballanze May 24 '16 at 17:31
  • Thanks man. Waiting for a better approach if there is any. This seems to be tweak but yes this would be my last option. – Debajit Majumder May 25 '16 at 03:58
  • Another query: is there any command by which I can check the list of assume-unchanged file when I will execute `git update-index --assume-unchanged `? because over the time if I do this for multiple files, it will be hard to remember, so it would be better if we have a command just like `git stash list`. – Debajit Majumder May 25 '16 at 04:05
  • @DebajitMajumder `git ls-files -v | grep ^[a-z]` – dizballanze May 25 '16 at 10:03