Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Reset file mode (chmod) changes when making a Git commit

Stanislav KhromovStanislav Khromov

Sometimes you copy files into your GitHub repository on top of existing files (for example, syncing some code from an external source).

This can cause the file mod / chmod to differ, for example some files are 0644 in the repo and 0755 from the folder you copy. Git picks up on this which can cause a lot of confusing diffs to sift through.

With this one-liner you can remove all the chmod file changes before making a commit:

git diff -p -R --no-ext-diff --no-color \
    | grep -E "^(diff|(old|new) mode)" --color=never  \
    | git apply

Source

Git

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 0
There are currently no comments.