Satchel
Satchel

Reputation: 16734

what do I do with 'deleted' files in git?

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~

Upvotes: 2

Views: 2207

Answers (2)

michaelgmcd
michaelgmcd

Reputation: 2439

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

Upvotes: 3

stackuser
stackuser

Reputation: 669

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.

Upvotes: 0

Related Questions