If you want to remove directory from remote repository after adding them to .gitignore? Use the following steps:
I’d do it with cherry-pick -n (–no-commit) which lets you inspect (and modify) the result before committing:
1 2 3 4 5 6 7 8 9 | git cherry-pick -n <commit> # unstage modifications you don't want to keep, and remove the # modifications from the work tree as well. # this does work recursively! git checkout HEAD <path> # commit; the message will have been stored for you by cherry-pick git commit |
If the vast majority of modifications are things you don’t want, instead of checking out individual paths (the middle step), you could reset everything back, then add in what you want:
1 2 3 4 5 6 7 8 9 | # unstage everything git reset HEAD # stage the modifications you do want git add <path> # make the work tree match the index # (do this from the top level of the repo) git checkout . |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.