I have forked a project on github and started messing around with it on my own machine, I want to commit the changes I have made back to my fork on github but without commiting the changes I have made to the .cfg file, since this contains things like db password etc
In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
What you probably want to do is this: git update-index --skip-worktree . (The third option, which you probably don't want is: git rm --cached .
Using the git rm –cached Command However, the git rm command provides the –cached option to allow us only to remove files from the repository's index and keep the local file untouched.
Use this:
git update-index --skip-worktree path/file.cfg
And to restore:
git update-index --no-skip-worktree path/file.cfg
Lastly, if you want to list files that are marked with skip-worktree
:
git ls-files -v | grep ^S | awk '{print $2}'
To simplify, you can make an alias for that in your $HOME/.gitconfig
:
[alias] ls-ignored-changes = !git ls-files -v | grep ^S | awk '{print $2}'
Then you can type just git ls-ignored-changes
. It even works with auto-completion if you have the git-completion
in place (for bash, tcsh, zsh).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With