-1

I use Bitbucket and discovered this morning that my repository stands at 1.5GB in size (yes, I know - I am new to VCSs and decided to push everything in the folder to the repository, including the R environment files which themselves can become enormous. Now I'm trying to fix that due to scenarios like this arising).

I have identified the files that I need to remove in order to reduce this (.RData files), but I want to know if there is a quick way to delete all files ending in .RData.

TL;DR: I have unwittingly committed loads of files (that I really didn't need to) across several branches and now I want to remove the ones that I have identified as unnecessary.

Note that I normally use Sourcetree but something went wrong so I need to clone these files again, and as such I want to greatly reduce the size before doing this via my browser; otherwise, the cloning process would probably take several hours.

Mus
  • 7,290
  • 24
  • 86
  • 130

2 Answers2

1

Since you have already added these .RData files to index of git, there is no other way than just search-delete them:

find . -name "*.RData" -type f -delete
git add --all
git commit -m "Removed .RData files"

If you would not have added them, then simply create .gitignore file in root dir and add

*.RData

to ignore these files.

If your branch contains not much commits, then you can re-create this branch with proper start

Justinas
  • 41,402
  • 5
  • 66
  • 96
  • How do I do this on the Bitbucket website? The trouble is that I don't have a cloned copy on my machine at the moment - this is what I want to do. The reason I want to remove the files is because the clone will take several hours if I begin the process with the `.RData` files included. – Mus Jul 17 '18 at 10:37
  • @MusTheDataGuy Well you can use their interface to delete files. But it will take too long if it's lots of these files. Maybe just start downloading and read some best-practices using git in meantime? Also note that these files will still be in your git history. – Justinas Jul 17 '18 at 10:40
  • I have been trying this but when I hit `...` then `Delete`, nothing happens. I would expect at least a prompt or even notification of some sort, but I get nothing - why might this be? (Also, I realised how much I have to learn around `git` so I already have this book on my Kindle and am going to be reading it today: https://git-scm.com/book/en/v2) – Mus Jul 17 '18 at 10:42
  • Actually, I have figured it out - I have to hit Edit first and then I can delete the file. – Mus Jul 17 '18 at 11:12
0

You can put *.RData in your .gitignore file and do a clean-up of the repo. It will delete untracked files (lots of good answers on this other subject matter on SO).

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • Good suggestion, but the problem is that I want to clone from my repository to my machine and thus want to remove the files from my online repository/backup before I clone it as it will take a very long time to complete otherwise. – Mus Jul 17 '18 at 10:34
  • 1
    @MusTheDataGuy Yes, I answered too hastily, Justinas' answer is better, go for it :-) – Romain Valeri Jul 17 '18 at 10:37
  • It will not ignore already committed files. Try commit file, add it to gitignore and edit it. – Justinas Jul 17 '18 at 10:37