Git untrack folder-Remove a folder from git tracking

6.7K    Asked by Aalapprabhakaran in Devops , Asked on Jun 3, 2021

I need to exclude a folder (name uploads) from tracking. I tried to run

git rm -r --cached wordpress/wp-content/uploads

and after that, I added the path to .gitignore

/wordpress/wp-content/uploads

but when I ran git status t they show up as deleted. If I try to commit the changes, the files will be deleted, not only removed from tracking.

What am I doing wrong?

I have also tried

git update-index --assume-unchanged 

but this seems to untrack only files. But I need to remove an entire folder (including subfolders) from tracking.

Answered by Naveen Raj
You can follow the following steps and commands to git untrack folder from my git repository without deleting it from my local machine.
Step 1. Firstly, you'd need to add the folder path to your repo's root .gitignore file.
path_to_your_folder/
Step 2. Remove the folder from your local git tracking, but keep it on your local system disk using this:
git rm -r --cached path_to_your_folder/Step 3. Push your changes to your git repo.
The folder will be considered "deleted" from Git's point of view (i.e. they are in the past history, but not in the latest commit, and people pulling from this repo will get the files removed from their trees), but stay on your working directory because you've used --cached
I hope this helps!


Your Answer

Answer (1)


In SQL Server, you can convert a varchar to an int using either the CAST or CONVERT functions. Here's how:

Using CAST:

SELECT CAST('123' AS INT) AS ConvertedValue;

Using CONVERT:

SELECT CONVERT(INT, '123') AS ConvertedValue;

These commands will convert the string '123' to an integer value of 123. Just ensure that the varchar value you're converting contains valid numeric characters, as attempting to convert non-numeric strings may result in errors.


5 Months

Interviews

Parent Categories