Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need to remove folder and contents from the repo but not on the server

Christopher Mendla April 21, 2018

I pushed from the production server to a repo that I just created. The server had a .gitignore but I think that didn't take effect because it wasn't in bitbucket yet. (I might be wrong on that?)

Here is what I did

  • Create the repo in bitbucket with nothing but a readme
  • Set the upstream on the server to the bitbucket repo
  • pulled the bitbucket changes (readme) to the server
  • Committed and pushed

The gitignore that was on the server ended up in the repo as expected. It contained entries such as

  • .gitignore
  • /log
  • /tmp
  • /public/system
  • /public/*.pdf

However the repo now has /log, /tmp etc.  It is extremely slow.

How do I fix this?   I've been looking at git rm -r --cached but I don't think that will work with the folders.

I've also seen git filter-branch.   I'm a bit unsure of the exact syntax I need.

 

To summarize:  My goal is to remove the folder/files that were listed in the original .gitignore from the repo. There were previous commits that show from the server. However, if I click on the commit link I get "something went wrong". I'm not particularyly worried about that right now.

What I want to do is get rid of the folders and files that shouldn't be in the repo.

thanks,

 

chris

temp - bitbucket for c.JPG

1 answer

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 23, 2018

 

Hi Christopher! The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked and looks like in your case they were already tracked. To stop tracking a file that is currently tracked, you need to use git rm --cached. For more details you can read Git ignore and Git rm.

 

This blog contains examples that might help you. As always, it's important to have a backup of your data before performing this kind of operations if you're not familiar with them. 

Hope that helps!

Ana

Christopher Mendla April 23, 2018

I'm going to try that. I was wondering though, if that would reduce the repo size from the 1 GB that it is currently to the 100k or so it should be.

From what I understand, there is a possibility that the folders I would be removing from the repo would still exist in previous commits.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events