Git
Everyday questions and answers!
Table of contents
- Create an empty git commit
- How to show only modified file using git?
- Reverting to specific commit in git and push it.
- Temporarily ignore changed or new files without altering
.gitignore
$ git commit --allow-empty
$ git status -uno -sb
$ git reset SHA
$ git push -u origin master --force
If the file is a changed repository file:
git update-index --assume-unchanged "$FILE"
To undo this, use the command:
git update-index --no-assume-unchanged "$FILE"
The update-index command doesn’t work with new files that haven’t been added to the repository yet, though.
If the file is new and not added to the repository:
Add its filename to the repository’s exclude file:
echo "$FILE" >> .git/info/exclude
This also works for changed repository files, but there isn’t a specific undo command for it. The exclude file would need to be edited and the filename deleted from it. Or other commands could approximate it:
ex -s -c"g/^${FILE}\$/d" -cwq .git/info/exclude
More - Ignore trivial changes to files