Link Search Menu Expand Document

Git

Everyday questions and answers!


Table of contents

  1. Create an empty git commit
  2. How to show only modified file using git?
  3. Reverting to specific commit in git and push it.
  4. Temporarily ignore changed or new files without altering .gitignore

  • Create an empty git commit

$ git commit --allow-empty

  • How to show only modified file using git?

Stack Overflow

 $ git status -uno -sb

  • Reverting to specific commit in git and push it.

Stack Overflow

$ git reset SHA

$ git push -u origin master --force

  • Temporarily ignore changed or new files without altering .gitignore

Gist

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


Copyright © ∞ Rishi Giri