github - git - Commit and push folder then stop tracking -


i need push dummy file in folder repo sit there unchanged , serve example. file located inside sub-folder so:

/main-repo/main-code.py /main-repo/.gitignore /main-repo/sub-folder/dummy-file.dat 

i can commit , push these files , folders without issues. need after tell git stop tracking sub-folder folder , contents while at same time keeping in repo (i use github)

i tried adding sub-folder/* .gitignore changes still being tracked. tried removing file cache with:

git rm --cached sub-folder/dummy-file.dat 

but removed file repo after pushed.

so recap: want first push of sub-folder/dummy-file.dat , after stop tracking changes any file inside subfolder while keeping initial state of subfolder in repo.

is possible?

i think looking assume-unchanged flag of update-index - allow local changes tracked file ignored git.

git update-index --assume-unchanged <file> 

from git-update-index man page

when these flags specified, object names recorded paths not updated. instead, these options set , unset "assume unchanged" bit paths. when "assume unchanged" bit on, git stops checking working tree files possible modifications, need manually unset bit tell git when change working tree file.

to undo effect of above, use:

git update-index --no-assume-unchanged <file> 

so, after initial push, use --assume-unchanged on each of files, , git never consider files change, or include them in add or commit operations.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -