Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

git - Only push files with certain extensions to GitHub

I am working on a data analysis project whose directory structure looks like following

pipeline1.py
pipeline2.py
...
pipelineN.py
data/
config/
test/

where folder data/ mixes a lot of data processing Python scripts and raw data.

Now I am almost done with the data preprocessing in data/ and ready to commit changes to my personal GitHub repo. However, I am not sure how could I push only .py in this folder.

I have tried adding following to .gitignore but this will ignore the data/ entirely and hence not desirable.

!*.py

data/
question from:https://stackoverflow.com/questions/65862018/only-push-files-with-certain-extensions-to-github

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

1 Answer

0 votes
by (71.8m points)

You should use that way:

first ignore everything in that folder

data/

than except those files

!data/*.py


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...