简体   繁体   中英

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

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

git add --all
git reset --hard HEAD

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM