Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing build folder from git

Tags:

git

android

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)

like image 572
DJphy Avatar asked May 17 '16 10:05

DJphy


People also ask

How do I remove a folder from my git repository?

Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains. This Git repo remove command also allows you to delete the Git repo while allowing all of the other files and folder to remain untouched.

How do I delete build files?

Go to folder properties/security and check if your name is listed as the owner. Also, make sure you mark the "full control". This will surely delete the folder. Next time when you run Android Studio, the necessary build stuff will be created by Android Studio.

How do I remove unwanted files from git?

Git can help you clean up files that you have told it you don't want. The command git clean -n will show you a list of files that are in the repository, but whose history Git is not currently tracking. A similar command git clean -f will then delete those files.


2 Answers

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.

like image 190
Som Bhattacharyya Avatar answered Oct 16 '22 05:10

Som Bhattacharyya


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

like image 39
tymbark Avatar answered Oct 16 '22 05:10

tymbark