GIT: Remove files from a repository without Removing them locally

Oweis Yahya
Dec 25, 2020
gitignore

From time to time, we forget to add files to .gitignore before we push our changes, it can be tricky how we can remove those files from the repository without deleting them locally, below you will find how to untrack files step by step:

Step 1:

Before starting, make sure all your changes are already committed. so you don’t lose any important changes you were working on.

Step 2:

After committing our changes, now clear your repository using the cmd below:

git rm -r --cached .

Step 3:

Add everything again:

git add .

Step 4:

Commit your changes:

git commit -m "untrack uneeded files/folders"

Now, push everything and go check your repository.

--

--

Oweis Yahya

A typical millennial techie but I travel back in time when I need music