2015-05-01 49 views
1

我已經定義了我的.gitignore並刪除了本地的相應文件,但它們仍然出現在我的回購中。從回購中刪除文件

如何強制我的回購使用我的本地版本?

感謝

回答

0

一旦文件被刪除本地(與git rm --cached),你仍然需要做的:

git add -A . 
git commit -m "record deletion" 
git push 

然後那些相同的文件將無法看到了你的遠程回購。

由於Andrey Tyukin評論below,這當然不會從歷史記錄中刪除文件。
但是,對於經過版本控制和錯誤推送的文件來說,這似乎是合適的,只需簡單地忽略它。

將其從回購的歷史記錄中刪除:「GitHub: Remove sensitive data」。


如果不工作:

  • 克隆本地遠程回購(其他地方)
  • 遵循 「How can I Remove .DS_Store files from a Git repository?

    # remove any existing files from the repo, skipping over ones not in repo 
    find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch 
    # specify a global exclusion list 
    git config --global core.excludesfile ~/.gitignore 
    # adding .DS_Store to that list 
    echo .DS_Store >> ~/.gitignore 
    

然後git的添加,承諾和推動。

+0

備註:這不會從歷史記錄中刪除文件。如果這些文件中存在某些機密信息,則必須進行過濾分支。 –

+0

它返回「沒有提交(工作目錄乾淨)」「一切都是最新的」 – Paul

+0

@Paul你是用簡單的'rm'還是用'git rm'刪除文件? – VonC