0

I found it is different from what others met. I have two problems:

  1. Git push with the user named 'v3' (this user is not mine). The command:

screenshot of mingw64 console

but Git push with the user named 'v3'.

  1. After I removed the 'push' right of user 'v3', it told me 'pre-receive hook declined' when I ran git push

Error message:

Total 9 (delta 4), reused 0 (delta 0)
remote: GitLab: You don't have permission        
error: failed to push some refs to 'http://gitlab.zank.mobi/zank/zank_live_service.git'
To http://gitlab.zank.mobi/zank/zank_live_service.git
!   refs/heads/develop:refs/heads/develop   [remote rejected] (pre-receive hook declined)
finnmglas
  • 1,047
  • 3
  • 14
  • 28
liu shuai
  • 43
  • 1
  • 1
  • 5

2 Answers2

2

Your can do an interactive rebase to change the commit author.

git rebase -i {commit hash here}

Then change action in front of commit to edit and save. After saving use following command to change author and complete rebase.

git commit --amend --author="New Author Name <newemail@address.com>"
git rebase --continue

Then you can check your commits using git log. The author in the said commit should be the new author.

When you push use git push --force-with-lease

Update

"pre-receive hook declined" - This error might be due to reasons mentioned in answers below.

  1. Git push error pre-receive hook declined
  2. Git error when trying to push -- pre-receive hook declined

There is a script hooked which checks if the commits being pushed are good enough, if not then it declines it and gives this error. So check git log to get the commits you are pushing and check here if any commits are from the user who does not have permission or there is some code in one of the commits which triggers that error.

Community
  • 1
  • 1
Shivam Mathur
  • 1,510
  • 11
  • 19
  • Yes, I have cloned the repository just a moment ago. The command is 'git clone http://username:pwd@gitlab.zank.mobi.com/zank/${project}.git'. Problem was fixed! but what i was confused is my push url was changed to that mentioned above. i am sorry my English is so poor. very sorry. – liu shuai Sep 08 '16 at 06:50
  • it is very interesting! the user 'v3' mentioned above was removed. The current user is my own, now. After this, i cloned the repository with the command 'git clone http://gitlab.zank.mobi/zank/zank_live_service.git ', I found everything was OK. – liu shuai Sep 08 '16 at 07:00
0

Your commit is not compatible with the repository maintainer's rules, you just need to git reset --hard HEAD ~ 1 After that commitment according to the maintainer's rules is ok

  • Give a link to the offcial doc of reset, and be carrefull with the hard option. – YLR Feb 11 '21 at 05:54