简体   繁体   中英

Ignoring files from getting added to the repo in git

I am learning to use git. I started with a small project and did git init inside the project directory. Then I added all files to the staging area by doing git add * .

But then I realized, I did not want to add a certain dir named "target" .. so I did a git reset HEAD and added a .gitignore file inside .git/ with the following contents

#python specific
*.pyc

# backup files to ignore
*~

# directories to ignore
target/

Now when I do git status I can see /target appearing under untracked files.

If I am not wrong, now if any already tracked file is changed and directly committed by git commit --a then target/ doesn't get committed since it has not been added yet.

But what if I had to do a git add * again ? (for eg. to conveniently add a lot of new files created in the project) Will this dir get added to the repo ? or is it that it will get ignored but will continue to appear in the list of untracked files regardless ?

Of course I can try this out but don't want to mess things up :)

Thanks

Since you've added the directory /target to your gitignore file this directory will never be added, even when you do git add *. :)

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