In our git repository for a latex project, pdf files are set to be ignored. Some still manage to push the compiled pdf, which makes the occasional pull a conflict between my local and the remote pdf, as it returns: "Your local changes to the following files would be overwritten by merge"
Is there a git feature that does this: "always ignore remote changes to this file", ideally synced with what's listed in the .gitignore
?
I could solve this
(1) by agreeing that no ones pushes files that are on the ignore list and reverting the corresponding changes (several mixed commits by now),
(2a) by ignoring my changes via an alias for rm that-file.pdf && git pull
or similarly
(2b) by backing up that file and overwriting the pulled change. Or
(3) I could always build my latex-project into a build folder, and remember that when I need the current pdf.
Answers for similar problems:
- pushing the pdf removal for everyone is a good approach, but I don't want to cause remote changes in that matter (let us assume the person pushing the PDF is happy to be able to open the file from the web-interface, too)
- force git pull via
git fetch --all && git reset --hard origin/master
would not only overwrite my pdf (which is ok, although I'd prefer to ignore the remote change), but I'd risk losing local changes out of the .gitignore scope, too. --assume-unchanged
is getting in the right direction, but cannot handle regular updates to the remote pdf- this question is similar, but asks to skip all conflicting remote updates (while I appreciate a pull failing due to a conflict, as long it doesn't concern a file on the ignore list)
edit:
git hooks are potentially helpful here (see comments below).
- Unfortunately, pre-pull hooks don't exist although they could help individuals keeping a normal workflow without asking other people anything.
- A server-side hook can reject the commit with an error message and maybe it can also just rename the commited pdf
- A client-side pre-commit
hook
can help to avoid commits not respecting the
.gitignore