Jose Gallo
Jose Gallo

Reputation: 134

How can I delete untracked files and folders in git

I am starting with Git and Github and with git status command it is throwing this:

On branch master Your branch is up-to-date with 'remotes/reflections/master'. Untracked files: (use "git add ..." to include in what will be committed)

    .DS_Store
    .Rhistory
    .Trash/
    .android/
    .bash_history
    .bash_profile
    .bash_profile.swp
    .dropbox/
    .gitconfig
    .oracle_jre_usage/
    .rstudio-desktop/
    .subversion/
    .viminfo
    1.Sueña/
    AndroidStudioProjects/.DS_Store
    Applications/
    Desktop/
    Downloads/
    Library/

nothing added to commit but untracked files present (use "git add" to track)

It is giving to me name of directories like Desktop/ or Librery/ ...

I have tried with git reset --hard but it isn't working.

How can I delete these untracked files and folders without deleting them from my computer irreversibly.

Any help, will be appreciated

Thanks in advance

Upvotes: 1

Views: 6475

Answers (4)

Ankit Bhatnagar
Ankit Bhatnagar

Reputation: 755

There's a .gitignore file in the base directory. Put all these files or paths of these files in it. Then they'll not come during git status.

Don't do git add or git commit, else you'll see a hard time dealing with these files.

Upvotes: 0

Vinnie James
Vinnie James

Reputation: 6042

You may want to try moving all those folders/files out of your repo temporarily. Do a git add . commit/push. Then move the ignored files back into your repo. This will be certain to remove your unwanted files from the remote repo

Upvotes: 0

tglassner
tglassner

Reputation: 11

Sounds like you're looking for gitignore: https://git-scm.com/docs/gitignore

"A gitignore file specifies intentionally untracked files that Git should ignore."

Upvotes: 1

orvi
orvi

Reputation: 3340

You need to add all of them first and reset the repo:

git add --all
git reset --hard HEAD

Upvotes: 2

Related Questions