iT邦幫忙

0

Git認證問題

最近公司將版控系統從SVN轉至GIT
GIT的系統是使用GitLab

我發現使用Command line去任意更改作者資訊

git config --global user.name "test"
git config --global user.email "test@hotmail.com"

在將本機的COMMIT推送到遠端時,雖然會跳出認證訊息,
這時我使用我正確的帳號密碼去認證(假使在這邊是claire.chang)
就可以順利的將修改的檔案push上去

但我的問題是,GIT的系統上顯示的作者名稱會是
Author: test <test@hotmail.com>
而不會是我們用來認證gitLab的claire.chang(這個身份才是對團隊其他人有意義的)

想請問這是正確的情形嗎?我們該如何去防止團隊人員用此方法匿名push不該修改的內容呢?

註: GitLab網頁介面有一個activity可以看到真實上傳的人員,但儲存的筆數似乎有限,無法撈到所有的資料
http://claire-chang.com/wp-content/uploads/2017/11/2017-11-02_182319.png

這跟分散式架構的版本控制有關係,顯示 push 的人也是不切實際的,正確的作法,應該從版控流程著手。
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
海綿寶寶
iT邦大神 1 級 ‧ 2017-11-03 09:32:13
最佳解答

簡單的答案是:辦不到

這個 2012 年的 issue 回答了所有的問題,值得一看

以下節錄部份精彩內容

When creating a commit, Git will only use the name and email configured on your local system (as @mmonge described). It will create a commit and fill in the author and committer information accordingly (this is just meta data for a commit, you cannot really "enforce" anything here).

Once your push is done, your commits will show up on the GitLab web interface. When displaying commits GitLab will look at the committer and author information and will try to find a GitLab user with that name or email address and link to his/her profile. If the commit author does not have an GitLab account (as with outside contributions) it will just display the infos found in the commit.

回到你的問題本身,有兩個答案,但你可能都不喜歡
1.Signing git commits with your GPG key
2.Maybe in combination with Git's server-side hooks. But GitLab doesn't support pre-receive hooks at the moment.

另外
既然要由SVN轉Git了
這篇30天精通Git版本控管
是本站2013年鐵人賽活動的冠軍作品
建議你可以花點時間閱讀
必有收獲

我要發表回答

立即登入回答