DJphy
DJphy

Reputation: 1302

Removing build folder from git

I have pushed a build folder to my remote repo; but the .gitignore file clearly has this line (/payu_ui/build); But i found out since the build files were already tracked once and now that i wrote a line in .gitignore will not really ignore the build folder. So i want to remove it from git from being tracked (the complete build folder) so i used this command

git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch payu_ui/build/' --prune-empty --tag-name-filter cat -- --all

But every time i run this command it gives an err saying

fatal: bad revision 'rm'

So what is going wrong; every time i click the commit option from IDE it shows that 1300 files needs to be committed (its annoying me)

When commit is cliked from IDE

Any help will be appreciated;
1. I dont want to track these build files(from payu_ui lib) 2. I dont want to push them to remote repo (but its already thr and beleive once i track from local and push them it gets deleted in remote repo; if it doesn't i'll manually delete in remote repo)

Upvotes: 11

Views: 14200

Answers (2)

tymbark
tymbark

Reputation: 1369

remove those build files (or whole folder) from your computer

rm -r [direction to files]

then add, commit and push all your changes (actually the change will be removing those files from repository), if you have set .gitignore file properly, git will stop tracking those files

Upvotes: 4

Som Bhattacharyya
Som Bhattacharyya

Reputation: 4112

Well you may just do the following,

  • Remove the line from gitignore for now.
  • Locally delete the folder.
  • Push out the change so the folder gets deleted from remote as well.
  • Now add the line to gitignore.

I recently faced the problem and that is what i did.

Upvotes: 32

Related Questions