Reputation: 63
I have a directory in the format: ~/models/*/*
, where the second *
represents 220 directories named hmm0
to hmm220
.
I only want to include the last directory in the commit, which I have managed to do with the .gitignore file using a sequence of !
and ignore lines (this already works):
!models/
models/*
!models/*/
models/*/*
!models/*/hmm220/
However, the issue is that the number of directories can change. For example, I may have 240 directories the next time named from hmm0
to hmm240
. I want to always only take the last directory (and ignore previous ones). Is this possible, and if so how? If not, is there a better solution than just having to change the .gitignore file each time the number of directories change?
Upvotes: 0
Views: 67
Reputation: 1841
I would readjust the models
directory, so to keep the important one in current
and don't sync the archives.
In your code you would then implement something like(not working BASH ;) ):
archive_count=`ls -l | grep "^d" | wc -l`
mkdir /models/archive/hm$archive_count
mv /models/current/* /models/archive/hm$archive_count/
models
|-archive
|-hm0
|-hm1
|-current
|-current files
.gitignore
!/models/archive
/models/archive/*```
Upvotes: 0