简体   繁体   中英

How to ignore a directory in git

So the latest version of the GoogleMaps framework is 123MB, which causes all kinds of problems with GitHub's 100MB limit. I tried Large File Storage , but that doesn't work. So now I'm trying to ignore my Pods directory. I edited my .gitignore file to look like this:

# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/

But when I try to push, I still get the same file-too-large error from the GoogleMaps Pod. What am I missing?

EDIT: Here's the exact error for those that don't believe it:

File Pods/GoogleMaps/Frameworks/GoogleMaps.framework/Versions/A/GoogleMaps is 123.00 MB; this exceeds GitHub's file size limit of 100.00 MB

This is a GitHub problem.

You will need to make sure that the file is not in your repo at all. This means removing the file from all commits. Adding a file to .gitignore does not remove files from Git if you have already added them, and removing a file from the latest commit does not remove the file from the repo because the file still exists in the repo history (in other words, git rm does not help).

To completely remove the file, edit history. See: Completely remove file from all Git repository commit history

Try this

git update-index --assume-unchanged '/pods' then do git status just to make sure what we are going to commit. Now this time it should not include "pods" directory.

Hope this helps?

The .gitignore looks good to me. I can think of the following causes, why you are still hitting the 100MB limit:

  • you already added the Pods directory but did not commit it so far. In this case git rm --cached <filename> is your friend
  • you committed the Pods directory in an earlier commit. Since git uploads all intermediary changes between the remote version and the local version, the Pods directory would be uploaded, even if it was removed again in a more recent commit. In this case, the only way to remove the Pods directory from your history is git rebase .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM