简体   繁体   English

完全删除git仓库

[英]Completely remove git repository

I've create a repository in GitHub and tried to commit files over the size limit. 我已经在GitHub中创建了一个存储库,并尝试提交超出大小限制的文件。 This caused an error message. 这导致了错误消息。 I've then created a .gitignore file which I saved in the main directory of my project which include a rule to exclude all .csv files. 然后,我创建了一个.gitignore文件,该文件保存在项目的主目录中,其中包括一个排除所有.csv文件的规则。

# History files
.Rhistory

# Example code in package build process
*-Ex.R

# R data files from past sessions
.Rdata
.Rd

# .csv files which in this case are too heavy (> 100mb)
# You can download training and test datasets at this URL --> http://www.kaggle$
.csv

I've then tried to commit it again but unfortunately Git tries to commit also the .csv files along with the new create .gitignore file. 然后,我尝试再次提交它,但是不幸的是,Git尝试也提交.csv文件以及新的create .gitignore文件。

Considering the .gitignore way didn't sort my issue I've tried to remove the cached file using this command and tried to push again: 考虑到.gitignore方法无法解决我的问题,我尝试使用此命令删除缓存的文件并尝试再次推送:

$ git rm --cached data/train.csv data/test.csv
$ git commit -m "Remove heavy .csv files
$ git push -u origin master

Unfortunately also in this case Git is trying to upload the .csv files. 不幸的是,在这种情况下,Git仍试图上载.csv文件。 I think I need to origin the master branch because in GitHub the repository is still empty. 我认为我需要启动master分支,因为在GitHub中存储库仍然是空的。

BTW, a git status command returns no new files to commit. 顺便说一句, git status命令不返回任何新文件来提交。 The

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       data/
nothing added to commit but untracked files present (use "git add" to track)

What should I do? 我该怎么办?

Considering that: 考虑到:

  • your most recent GitHub repo is empty, 最近的GitHub存储库为空,
  • and that you have already committed your large file (meaning no amount of git rm --cached will purge that file: it removes it only from the index) 并且您已经提交了大文件(意味着没有git rm --cached会清除该文件:它只会从索引中删除它)

Ianh 's advice is the easiest: 伊恩建议是最简单的:

  • reinitialise a new local repo, 重新初始化一个新的本地仓库,
  • write first your .gitignore file (with *.csv , not .csv ) 首先编写您的.gitignore文件(使用*.csv ,而不是.csv
  • then add everything (all .csv files won't be added) 然后添加所有内容(不会添加所有.csv文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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