Pages

Saturday, June 12, 2021

Git : How to unversionned files ?

Sometimes, I commit files I don't want.This reminder explain how to remove theses files from GIT.

First, you can list files managed by your GIT repositories :

git ls-files => list des fichiers versionnés
git rm --cached .idea

Then, you have to delete unwanted files.In my case, I commited the .idea directory :

git rm -r --cached .idea
rm '.idea/$CACHE_FILE$'
rm '.idea/.gitignore'
rm '.idea/misc.xml'
rm '.idea/modules.xml'
rm '.idea/php.xml'
rm '.idea/vcs.xml'
rm '.idea/yuzu.iml'

If you check the status, you are going to see delete files :

git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
        deleted:    .idea/$CACHE_FILE$
        deleted:    .idea/.gitignore
        deleted:    .idea/misc.xml
        deleted:    .idea/modules.xml
        deleted:    .idea/php.xml
        deleted:    .idea/vcs.xml
        deleted:    .idea/yuzu.iml

You only have to execute the commit command : git commit -m "Delete unwanted files"

The last step is to add the unwanted files or directory in the .gitignore file (.idea in my case) :

vi .gitignore 
.idea


GIT : version 2.17.0.windows.1

No comments:

Post a Comment

Débutez en crypto-monnaie de manière ludique avec les projets "Move to earn"

Les projets "Move to earn" sont des projets très en vogue en ce moment dans le monde de la crypto-monnaie. Le principe est simple ...