How can one dry run a git push to check whether one has write permissions to a remote?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 02:31:50

Shawn Pierce wrote the following about git push --dry-run:

A --dry-run doesn't send the commands the client would use from client to server, so the server can't tell the client if it would accept them or not. The entire --dry-run thing is client side only.

(my emphasis)

So, if there is a way to check whether one has write permissions to a remote, git push --dry-run is definitely not it.

Posting as an answer on the test I did where I don't think it works in my scenario. I'm creating a branch form another one without further changes

git clone ....
git checkout master
git branch -f test master
git push --dry-run origin test

and it passed even though I have zero push permissions on this server/repo combo

To ssh://<server>/repo
 * [new branch]      test -> test

Pushing without dry-run hits the error condition I was expecting

git push origin test
Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done    
To ssh://<server>/repo
 ! [remote rejected] test -> test (can not create new references)
error: failed to push some refs to 'ssh://<server>/repo'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!