I need some generic command (without specyfing any branches name), that will give me list of files that will be pushed in git push. There might be few commits on branch that will be pushed. So basically I'd like to get all files from local commits. I guess I'd need to compare to last commit that is on remote, but I don't know how to do it
I need it because I want to add pre-push git hook that will lint files that are being pushed.
I tried
git diff @{upstream} --name-only
and it does what I need, but it only works if I have upstream of branch set. Otherwise I'll get error fatal: no upstream configured for branch <branch-name>
Is there any way to do it in generic way even for branches without upstream set?
I found answer to my question:
This will give me hashes of all commmits that are on my local branch, but on on remote.
I just need diff between most recent commit and parent of the first commit:
And this will output list of files that will be pushed to the remote