1

I am using git, and i do not want to add, commit some folder but it show me in modified files. How can stop this.

it show me in

git status 
1
  • Update us with what the nature of this folder is. Does this folder contain source files which you would eventually want to commit to your repository? Does the folder contain local config files? Or, is it something else? Commented Jul 4, 2016 at 5:02

5 Answers 5

1

To unstage a file or folder which you accidentally added, use git checkout -- path/to/file_or_folder:

git checkout -- path/to/your/file.ext 

or

git checkout -- path/to/your/folder 
Sign up to request clarification or add additional context in comments.

3 Comments

After you checkout the folder, add it to .gitignore.
@IvanRubinson That would assume that the folder is not already versioned (which presumably it is not).
how to use gitignore?
1

Step 1. 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 disk.

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 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.

Reference : Remove a folder from git tracking

Comments

1

You can add specific files by the following command.

git add filename 

and then commit the code. You will be able to push only the specified files in this case.

Also, as an alternative you can update .gitignore file and specify the files what you don't want to commit.

Comments

0

If you want to ignore it permanently, add it to .gitignore file.

Just create a file in your repo with .gitignore filename and add relative folder path there.

Here is the documentation link - https://help.github.com/articles/ignoring-files/

3 Comments

To ignore a directory, in .gitignore: directory/* (ignores all files in a folder called "directory")
where i need to add this file in .git folder or in project root
It should be in same directory where your .git folder is (which usually is your project root)
0

you can use the .gitignore then inside the .gitignore file include the folder name for example test/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.