Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
235 views
in Technique[技术] by (71.8m points)

github - How to add folders except few using git add

I am getting this error in VSCode stating "

This git repository has too many active changes, only a subset of git features will be enabled

"

I am probably getting this because of my eclipse .metadata folder and folders like .history and .settings.

I wanted to exclude these folders while adding the others in git repo so I tried this :

git add -- . :!.history :!.metadata :!.settings

and this too,

git add --all --:!.history :!.metadata :!.settings

but getting error

bash: !.history: event not found

How do I solve it, I have updated my git software but it doesn't seem to be fixing it.

question from:https://stackoverflow.com/questions/66066331/how-to-add-folders-except-few-using-git-add

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error you are getting is not specific to git but specific to bash where the ! character is related to bash history, to achieve what you are trying to do, you can escape the ! with ,

So something like

git add --all --:!.history :!.metadata :!.settings

But a cleaner approach will be to use a .gitignore file and add entries for each of the above directories for that.

So your .gitignore would look something like the following -

# contents of .gitignore
.history
.metadata
.settings

This .gitignore file should be at the root of our repository.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...