git exclude file from commit code example
Example 1: remove a file from git commit
git reset --soft HEAD^
or
git reset --soft HEAD~1
git reset HEAD path/to/unwanted_file
git commit -c ORIG_HEAD
Example 2: git ignore updates to file
git update-index --skip-worktree path/to/file.txt
Example 3: git exclude some files from git commit
To exclude some files from git commit
-----------------------------------------------
syntax - git update-index --assume-unchanged <filepath>
example - git update-index --assume-unchanged default/config.php
To undo the above command
-----------------------------------------------
syntax - git update-index --no-assume-unchanged <filepath>
example - git update-index --no-assume-unchanged default/config.php
Example 4: how to git ignore a file
git config --global core.excludesfile ~/.gitignore_global
Example 5: git ignore not saving changes
git rm -rf --cached .
git add .