Abhishek Bhatia
Abhishek Bhatia

Reputation: 9796

git pushes untracked files

~/D/s/b/h_adv_ML (master±) ▶︎︎ git ls-files --error-unmatch *.csv
test_rmse.csv
train_rmse.csv
error: pathspec 'genome-scores.csv' did not match any file(s) known to git.
error: pathspec 'genome-tags.csv' did not match any file(s) known to git.
error: pathspec 'links.csv' did not match any file(s) known to git.
error: pathspec 'movies.csv' did not match any file(s) known to git.
error: pathspec 'ratings.csv' did not match any file(s) known to git.
error: pathspec 'tags.csv' did not match any file(s) known to git.
Did you forget to 'git add'?
~/D/s/b/h_adv_ML (master±) ▶︎︎ git commit -m " clean3"
[master b31185a]  clean3
 2 files changed, 1 insertion(+), 465566 deletions(-)
 delete mode 100644 tags.csv
~/D/s/b/h_adv_ML (master) ▶︎︎ git push origin master
Counting objects: 36, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (36/36), 192.26 MiB | 2.17 MiB/s, done.
Total 36 (delta 12), reused 0 (delta 0)
remote: Resolving deltas: 100% (12/12), completed with 1 local object.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 70338ad9481eef83938b427ed955775e
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File genome-scores.csv is 308.56 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File ratings.csv is 508.73 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/<...>/h_adv_ML.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/<...>/h_adv_ML.git'

It tries to push them when they are not tracked! What am I missing here? I am not sure why it is trying to push "genome-scores.csv" and "ratings.csv" when they are untracked.

$ git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
 $ tree
.
├── README.md
├── README.txt
├── check.py
├── check_old.py
├── code.py
├── genome-scores.csv
├── genome-tags.csv
├── links.csv
├── movies.csv
├── old_code.py
├── ratings.csv
├── read_py.py
├── tags.csv
├── test_rmse.csv
└── train_rmse.csv

Upvotes: 0

Views: 2747

Answers (1)

Kevin Hoerr
Kevin Hoerr

Reputation: 2609

I've made a couple of comments already, but I think I've come up with a rather basic solution - you need to "squash" the commits since the last time you've pushed.

  1. Identify the last commit that's on the remote. You can do this with git log --oneline and look for the commit with origin/master next to it. Then copy the commit's ID, which is the hex string of ~7 characters at the beginning of the line.

  2. git reset COMMIT (e.g. git reset abcdef0) will take out all of the commits and 'unstage' them. This means that all changes made since that commit (including that commit) will be taken out of Git, but kept in your filesystem.

  3. Identify any changes made in the reset commits that you want to keep and recommit them. It should tell you the 'Unstaged changes after reset' after the previous command.

  4. You should be able to push the committed changes to the Github repository.


Slightly more programmatic version:

# get sha1 revision of origin/master and reset to that
git reset $(git rev-parse origin/master)

# git add via patch, so you can moderate what you add
git add -p

git commit
git push

Upvotes: 2

Related Questions