2

I have the following: "Changes not staged for commit:"

deleted:    .bundle/cache/le-2.6.2.gem
deleted:    .bundle/gems/le-2.6.2/.gitignore
deleted:    .bundle/gems/le-2.6.2/.travis.yml

This comes up everytime I type git status.

I feel like I messed up everything by doing git rm .bundle/* in the past so want to know what to do whenever I see a whole slew of things that say deleted that I am not using.

I have a similar list under : Untracked files: -- are they treated differently?

Update:

I did a git rm -r on things that were uncached in .bundle...and now my app doesn't work.

I think I only wanted to remove those that say "deleted".

What's the right way to handle .bundle files in git and how do I fix the current scenario?

When I do bundle clean' thenbundle install` it still cannot find the gems I need. Thanks~

Satchel
  • 16,414
  • 23
  • 106
  • 192
  • What does this have to do with [tag:ruby]? – Jörg W Mittag Jun 25 '15 at 08:52
  • The files listed under "changes not staged for commit" can be recovered by discarding your changes since last commit. Although you can later recover those files by reverting back to a commit when these files existed. See http://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repo – nsane Jun 25 '15 at 09:06
  • @nisargshah95 I would have included that in my answer except for "I see a whole slew of things that say deleted **that I am not using**." – michaelgmcd Jun 25 '15 at 11:20
  • @mgmcdermott I believe she does not know where these fies came from. Also, it does not seem very clear as to whether she wants to really delete them or keep them. – nsane Jun 25 '15 at 17:12
  • yes @mcgmcdermott -- I want to remove those files -- it shows whenever I saw `git status` and I don't use them. – Satchel Jul 07 '15 at 17:03

2 Answers2

3

Taken from this post, entering this command will remove files from your git repo that you have already removed from your disk:

git rm $(git ls-files --deleted)

Also note that running git add . will stage all untracked files, including any files you've deleted. So if you're ok pushing everything to your repo, git add . will work just fine (don't forget to commit and push).

Update

I had a little trouble understanding your comments so I've included a full circle create file, add/commit/push to repo, delete from local, remove from git/commit/push to repo. Hope it helps.

enter image description here enter image description here

Community
  • 1
  • 1
michaelgmcd
  • 2,369
  • 1
  • 18
  • 24
  • if I add untracked files that are deleted, what does that mean? – Satchel Jul 07 '15 at 17:04
  • Just like adding any other untracked files, the changes will be pushed to your repo and the files will be deleted from the remote. – michaelgmcd Jul 10 '15 at 15:11
  • okay, thanks, this explained the concept....these are currently tracked, deleted from disk, but whenever I show git status it clutters everything. – Satchel Oct 01 '15 at 00:26
  • I could delete them 1 by 1 using `git rm name of file` to check right? and your stuff will delete everything, correct? gave it the answer. – Satchel Oct 01 '15 at 00:27
  • really nice -- yes, I want to remove all files deleted from disk that keep coming up in a `git status` so your command at the top looks like the thing. – Satchel Oct 02 '15 at 04:43
  • I tried it, I get an `argument list too long` error -- tracing back to the post you linked to now.... – Satchel Oct 02 '15 at 04:45
  • Maybe this will help? http://stackoverflow.com/questions/17290587/remove-deleted-files-from-git-argument-list-too-long – michaelgmcd Oct 02 '15 at 14:34
0

The output of "git status ." would give the details of 3 things.

  1. modified files - The list of files which you modified locally

  2. deleted files - The list of files you had deleted which are already part of git repository. Please make sure that you keep these files back when you upload your changes (Creating Gerrit)

    How to keep them back: git checkout deletedFile

  3. untracked files: These are the files which you had introduced newly or generated automatically because of your build process. You may delete these files before upload your changes. You may keep these files if they are to be part of your Gerrit.

Community
  • 1
  • 1
stackuser
  • 629
  • 8
  • 19