【问题标题】:Unversion on Git在 Git 上取消版本
【发布时间】:2012-11-16 13:15:31
【问题描述】:

我正在设计和构建一个 iOS 应用程序,它使用本地 git 存储库进行版本控制。到目前为止,我的一切都在版本控制之下,包括“Design”之类的大文件夹,里面装满了我的 Photoshop 资产等。我现在已经向 repo 添加了一个远程位置,显然不想将 Design 文件夹提交到远程。

我用以下内容制作了一个.gitignore 文件:

# File Extensions #
###################
*.psd

# Folders #
###########
/Design/*

应该排除那个文件夹和任何 Photoshop 文档吗?

如何取消对现有设计文件夹的版本化(git rm 实际上删除了文件!)?另外,当我取消版本时,它会自动缩小巨大的 .git 文件夹吗?

非常感谢。

【问题讨论】:

    标签: git version-control commit bitbucket


    【解决方案1】:

    使用 git 你可以使用git rm --cached design/,这将保留文件。

    要将其从整个历史记录中删除,您可以尝试以下操作:

    $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch design/' \
      --prune-empty --tag-name-filter cat -- --all
    
    $ rm -rf .git/refs/original/
    
    $ git reflog expire --expire=now --all
    
    $ git gc --prune=now
    
    $ git gc --aggressive --prune=now
    

    参考:https://help.github.com/articles/remove-sensitive-data

    【讨论】:

      猜你喜欢
      • 2010-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 2019-02-12
      • 2015-01-13
      • 2021-03-02
      • 2014-08-05
      相关资源
      最近更新 更多