I am working on coffee script repo where all javascript files are already pushed to origin repo. My goal is to not showing files with extension .js in git status result before push. In other word, my goal is to hide this files at the particular moment. After i finish my work i would like to push commit with my changes and .js files. The fact that this files are in origin repo, .gitignore file does not help me. Thanks in advance!
CodePudding user response:
git status
can take a path spec. And pathspecs can be excluded.
For example:
Show only *.js
files in git status
:
git status *.js
Show all files except *.js
in git status
:
# Unix Shells
git status ':(exclude)*.js'
# or shorter
git status ':!*.js'
# For Windows shells you shouldn't use the 'quotes', like this:
git status :!*.js
CodePudding user response:
Maybe you are looking for git update-index
?
git update-index --assume-unchanged *.js
git update-index --no-assume-unchanged *.js
With the former these file are ignored (more detail see below). With the later everything is as before.
--[no-]assume-unchanged
When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.