.git完全不忽略
我创建了一个名为.git完全不忽略,git,gitignore,Git,Gitignore,我创建了一个名为探索性数据分析/Course Project 1/的目录,里面有文件house\u power\u consumpion.txt。我尝试将其推送到我的git repo,用于此项目,并收到一条关于家庭电力消耗.txt大小的警告,因此我添加了一个.gitignore文件,其中包含以下行: Exploratory\ Data\ Analysis/Course\ Project\ 1/household_power_consumption.txt 我试着按照贴出的解决方案去做,但这些都
探索性数据分析/Course Project 1/
的目录,里面有文件house\u power\u consumpion.txt
。我尝试将其推送到我的git repo,用于此项目,并收到一条关于家庭电力消耗.txt
大小的警告,因此我添加了一个.gitignore
文件,其中包含以下行:
Exploratory\ Data\ Analysis/Course\ Project\ 1/household_power_consumption.txt
我试着按照贴出的解决方案去做,但这些都不适合我。我总是收到相同的错误:
git push origin master
Counting objects: 31, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (28/28), done.
Writing objects: 100% (31/31), 20.48 MiB | 221.00 KiB/s, done.
Total 31 (delta 6), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: Trace: 491a8219bf1d3de4fd08a8e3ea253faa
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File Exploratory Data Analysis/Course Project 1/household_power_consumption.txt is 126.80 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/jd901215/DataScience_CourseraSpecialization.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/jd901215/DataScience_CourseraSpecialization.git'
这是我的项目的本地目录树:
├── Exploratory Data Analysis
│ └── Course Project 1
│ └── household_power_consumption.txt
├── .git
│ ├── branches
│ ├── COMMIT_EDITMSG
│ ├── config
│ ├── description
│ ├── FETCH_HEAD
│ ├── HEAD
│ ├── hooks
│ │ ├── applypatch-msg.sample
│ │ ├── commit-msg.sample
│ │ ├── post-update.sample
│ │ ├── pre-applypatch.sample
│ │ ├── pre-commit.sample
│ │ ├── prepare-commit-msg.sample
│ │ ├── pre-push.sample
│ │ ├── pre-rebase.sample
│ │ └── update.sample
│ ├── index
│ ├── info
│ │ └── exclude
│ ├── logs
│ │ ├── HEAD
│ │ └── refs
│ │ ├── heads
│ │ │ └── master
│ │ └── remotes
│ │ └── origin
│ │ └── master
│ ├── objects
| | ├── (Bunch of SHA-1 checksums I guess )
│ │ ├── info
│ │ └── pack
│ ├── ORIG_HEAD
│ └── refs
│ ├── heads
│ │ └── master
│ ├── remotes
│ │ └── origin
│ │ └── master
│ └── tags
├── .gitignore
├── LICENSE
├── README.md
└── R programming
├── README.md
├── Week 1 Programming assignment
│ ├── complete7.R
│ ├── complete.R
│ ├── corr.R
│ ├── pollutantmean.R
│ ├── .RData
│ ├── .Rhistory
│ └── specdata
├── Week 2 Programming assignment
│ ├── cachematrix.R
│ └── README.md
└── Week 4 Programming assignment
├── best.R
├── hospital-data.csv
├── Hospital_Revised_Flatfiles.pdf
├── outcome-of-care-measures.csv
├── .Rhistory
└── rprog-doc-ProgAssignment3.pdf
很抱歉发了这么长的帖子,但我正试图提供必要的信息。提前感谢在我添加该行时为我工作
Exploratory\ Data\ Analysis/Course\ Project\ 1/household_power_consumption.txt
忽略
我怀疑你不能推,因为你以前的承诺。虽然您正在本地删除它,但我认为以前使用该文件创建了提交。
检查“git log”,查看您在txt文件中签入的提交是否存在
如果是,执行
git reset --soft HEAD^
删除该提交(如果是最新的提交)
重置提交后,
在“git状态”中,如果您在以下位置看到该文件:
"Changes to be committed:" area, execute "git reset HEAD <file>".
"Changes not staged for commit:" area, execute "git checkout -- <file>".
“要提交的更改:”区域,执行“git reset HEAD”。
“未为提交暂存的更改:”区域,执行“git签出--”。
执行“git状态”,并检查文件是否位于“未跟踪文件:”区域
然后,将文件添加到.gitignore。它会起作用的。首先,值得注意的是,
.gitignore
条目一开始并不代表人们通常认为的意思。我过一会儿再谈这个问题
很明显,这个输出行:
remote: error: Trace: 491a8219bf1d3de4fd08a8e3ea253faa
告诉您,在您尝试推送的提交集中,哪个提交包含过大的文件
不过,为了达到这一目的,您必须了解一些关于git的事情,这些事情在各种文档中往往解释得很糟糕。(要获得一个好的解释,请参阅。)在这种情况下,需要知道的一件事是,git push
调用一个“remote”,另一台计算机上有自己独立的git存储库,然后您的git要求其他git接受您的任何新提交并将其添加到自己的存储库中
在本例中,您和git调用远程“origin”,这是“我最初克隆的地方”的标准名称 为了进行说明,下面是在分支
master
上克隆只有三个提交的源代码的简单情况:
他们的git:
C1如果删除txt文件并提交新文件夹会发生什么?如果可以的话,你能在新文件夹中创建一个小文件并成功提交吗?嗨@ShawnMehan!如果我在本地删除.txt,我会收到相同的错误。对不起,您仍然会收到一条关于您现在删除的txt文件大小的警告?是的,先生!甚至当我使用git rm-r--cached命令时。因此,我认为您应该还原本地文件以匹配远程文件。在这一点上,你更相信这一点,所以放下那些改变,让自己回到一个好地方。哇,这是一个非常详细的答案。谢谢,我会把它全部读一遍,然后问是否需要。我刚读完,再次感谢。我忘记接受了
C1 <- C2 <- C3 <- C4 <- C5 <-- master
$ git push origin master
$ git log 491a8219bf1d3de4fd08a8e3ea253faa
$ git show 491a8219bf1d3de4fd08a8e3ea253faa
$ git log --name-status
C4 <- C5 <-- [master, before rebase]
/
C1 <- C2 <- C3 <-- origin/master
\
C4' ... <-- temporary rebase branch
$ git rm --cached Exploratory\ Data\ Analysis/Course\ Project\ 1/household_power_consumption.txt
$ git commit --amend --no-edit
[master d106870] blah blah ...
$ git rebase --continue
C4 <- C5 <-- [master, before rebase]
/
C1 <- C2 <- C3 <-- origin/master
\
C4' - C5' <-- temporary rebase branch
C1 <- C2 <- C3 <-- origin/master
\
C4' - C5' <-- master