Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 229031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:43:54+00:00 2026-05-11T19:43:54+00:00

I would like to put a Git project on GitHub but it contains certain

  • 0

I would like to put a Git project on GitHub but it contains certain files with sensitive data (usernames and passwords, like /config/deploy.rb for capistrano).

I know I can add these filenames to .gitignore, but this would not remove their history within Git.

I also don’t want to start over again by deleting the /.git directory.

Is there a way to remove all traces of a particular file in your Git history?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:43:55+00:00Added an answer on May 11, 2026 at 7:43 pm

    For all practical purposes, the first thing you should be worried about is CHANGING YOUR PASSWORDS! It’s not clear from your question whether your git repository is entirely local or whether you have a remote repository elsewhere yet; if it is remote and not secured from others you have a problem. If anyone has cloned that repository before you fix this, they’ll have a copy of your passwords on their local machine, and there’s no way you can force them to update to your “fixed” version with it gone from history. The only safe thing you can do is change your password to something else everywhere you’ve used it.


    With that out of the way, here’s how to fix it. GitHub answered exactly that question as an FAQ:

    Note for Windows users: use double quotes (“) instead of singles in this command

    git filter-branch --index-filter \
    'git update-index --remove PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' <introduction-revision-sha1>..HEAD
    git push --force --verbose --dry-run
    git push --force
    

    Update 2019:

    This is the current code from the FAQ:

      git filter-branch --force --index-filter \
      "git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
      --prune-empty --tag-name-filter cat -- --all
      git push --force --verbose --dry-run
      git push --force
    

    Keep in mind that once you’ve pushed this code to a remote repository like GitHub and others have cloned that remote repository, you’re now in a situation where you’re rewriting history. When others try pull down your latest changes after this, they’ll get a message indicating that the changes can’t be applied because it’s not a fast-forward.

    To fix this, they’ll have to either delete their existing repository and re-clone it, or follow the instructions under “RECOVERING FROM UPSTREAM REBASE” in the git-rebase manpage.

    Tip: Execute git rebase --interactive


    In the future, if you accidentally commit some changes with sensitive information but you notice before pushing to a remote repository, there are some easier fixes. If you last commit is the one to add the sensitive information, you can simply remove the sensitive information, then run:

    git commit -a --amend
    

    That will amend the previous commit with any new changes you’ve made, including entire file removals done with a git rm. If the changes are further back in history but still not pushed to a remote repository, you can do an interactive rebase:

    git rebase -i origin/master
    

    That opens an editor with the commits you’ve made since your last common ancestor with the remote repository. Change “pick” to “edit” on any lines representing a commit with sensitive information, and save and quit. Git will walk through the changes, and leave you at a spot where you can:

    $EDITOR file-to-fix
    git commit -a --amend
    git rebase --continue
    

    For each change with sensitive information. Eventually, you’ll end up back on your branch, and you can safely push the new changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 153k
  • Answers 153k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By default, there is no such feature yet (I'm using… May 12, 2026 at 10:19 am
  • Editorial Team
    Editorial Team added an answer It should be map.resources :papers I could only get the… May 12, 2026 at 10:19 am
  • Editorial Team
    Editorial Team added an answer you can't generate the table from calling stored procedure. However,… May 12, 2026 at 10:19 am

Related Questions

I'm trying to add the output of git describe to the about window of
I would be interested to in knowing how you out there handle the bumping
I have changes to a file, plus a new file, and would like to
I'm doing a web app, and I need to make a branch for some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.