# \[solved\] Force commit author to username?

**URL:** <https://forum.gitea.com/t/solved-force-commit-author-to-username/1887>\
**Category:** Install/Maintain/Configure\
**Created:** [February 4, 2020, 11:29pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887 "2020-02-04T23:29:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![0x6d61726b](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/0x6d61726b/32/1122_2.png) [@0x6d61726b](https://forum.gitea.com/u/0x6d61726b)\
**Post date:** [February 4, 2020, 11:29pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/1 "2020-02-04T23:29:26Z")

</div>

I am pretty new to Gitea and made a testinstallation, so I hope my question does not sound to stupid.

I created a test repository and a testfile

- commit #1 from remote machine with TortoiseGit and an user info name “foo”
- commit #2 from web interface (username “testuser”)
- commit #3 again from temote machine but with user info name “testuser”

The only commit that was linked to the testuser is the one created on the web interface, but none from the remote location. All commits were made with the the testusers’ credentials.

Is there an option I did not yet find on the cheat sheet or documentation to force/link the Author of a commit to the username it was committed from? I would expect all three Authors to be “linked” to the testuser.

 ![gitea-commit-user](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/1X/e2b03a780a3affb3bb6fb3c20ff9d1453ae2d8ba.png)

---

<div class="post-metadata">

**Author:** ![jolheiser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jolheiser/32/4807_2.png) [@jolheiser](https://forum.gitea.com/u/jolheiser)\
**Post date:** [February 5, 2020, 3:05am UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/2 "2020-02-05T03:05:36Z")

</div>

Gitea links commits by email address, so in order to link those commits they would need to send in a full signature with an email.

---

<div class="post-metadata">

**Author:** ![0x6d61726b](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/0x6d61726b/32/1122_2.png) [@0x6d61726b](https://forum.gitea.com/u/0x6d61726b)\
**Post date:** [February 5, 2020, 5:27pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/3 "2020-02-05T17:27:58Z")

</div>

Thanks for that information John. I was able to make the desired commit, but run into another issue.  
I was able to fake an “Administrator” commit from the non-priviledged testuser account:

 ![gitea-commit-user2](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/1X/bae707d16215fa24e7a93f4246ee0165c3114240.png)

I think it should not be possible and forbitten by all means to commit as another user just by knowing the users email address (and maybe the display name to look 100% genuine). Was this already discussed before?

---

<div class="post-metadata">

**Author:** ![jolheiser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jolheiser/32/4807_2.png) [@jolheiser](https://forum.gitea.com/u/jolheiser)\
**Post date:** [February 5, 2020, 5:41pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/4 "2020-02-05T17:41:07Z")

</div>

This is actually the reason to sign your commits with GPG. If you take a look at [this repository](https://github.com/jolheiser/Test/commits/master) on GitHub, you will see the latest commit appears to be from @techknowlogick when in fact I simply spoofed a commit.

---

<div class="post-metadata">

**Author:** ![0x6d61726b](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/0x6d61726b/32/1122_2.png) [@0x6d61726b](https://forum.gitea.com/u/0x6d61726b)\
**Post date:** [February 5, 2020, 6:13pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/5 "2020-02-05T18:13:39Z")

</div>

Ok , I see, but don’t understand what the benefit is. So it is basically a feature of git?

Is there a way (e.g. implementing a configuration flag) to disallow this?  
I have not yet found the right starting point in the gitea files.

---

<div class="post-metadata">

**Author:** ![jolheiser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jolheiser/32/4807_2.png) [@jolheiser](https://forum.gitea.com/u/jolheiser)\
**Post date:** [February 5, 2020, 6:16pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/6 "2020-02-05T18:16:15Z")

</div>

Enforcing signed commits is configurable per-repository in branch protection settings in `1.12.0` and above.  
We are currently working to release `1.11.0`, so `1.12.0` may be a way off yet.

Until then, I believe you can enforce signed commits with git hooks. [Example](https://github.com/github/platform-samples/blob/master/pre-receive-hooks/block_unsigned_commits.sh)

---

<div class="post-metadata">

**Author:** ![0x6d61726b](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/0x6d61726b/32/1122_2.png) [@0x6d61726b](https://forum.gitea.com/u/0x6d61726b)\
**Post date:** [February 5, 2020, 6:23pm UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/7 "2020-02-05T18:23:13Z")

</div>

Yes, I noticed that 1.11.0 is in pre-release state which I already have installed on a container for testing.  
Thanks a lot for the example and the information that there is an upcoming solution in the near future.  
I will implement the block script for now.

Thanks John 🙂

---

<div class="post-metadata">

**Author:** ![techknowlogick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/techknowlogick/32/4706_2.png) [@techknowlogick](https://forum.gitea.com/u/techknowlogick)\
**Post date:** [February 17, 2020, 3:51am UTC](https://forum.gitea.com/t/solved-force-commit-author-to-username/1887/8 "2020-02-17T03:51:58Z")

</div>


