Search code examples
ruby-on-railsgitgithubheroku

How to Remove Public/Assets Files From a Branch on Github?


We mistakenly pushed many public/assets files to a branch on github, but we don't want any of those files there (Apparently, if we then push to Heroku, it will cause problems).

OUR QUESTION: Is there a way for us to remove the public/assets files from the github branch without affecting any of the other files? Our only alternative is to recreate the branch from scratch, which would take days. So we are trying to avoid that.

We are using Ruby on Rails.

Thank you!


Solution

  •  1. git fetch origin
    
     - this allow to fetched the changes from the remote repository (origin) but does not merge them into your local branches, an updates your local reference to the remote branches.
    
    
     2. git checkout <branch_name>  
     
     -  switches your working directory to the specified branch ex.(<main>). It updates both your working directory and the HEAD to the latest commit of the specified branch.
    
    
     3. git pull origin <branch_name>  
    
     - pulls the latest changes from the remote repository (origin) for the specified branch ex.(<main>). It combines the git fetch and git merge steps into a single command, updating your local branch with the latest changes 
     
     4. git rm -r public/assets 
     -   and this removes the specified directory (public/assets) from your working directory.