<style> html, body, .ui-content { background-color: #333; color: #ddd; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { color: #ddd; } .markdown-body h1, .markdown-body h2 { border-bottom-color: #ffffff69; } .markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { color: #fff; } .markdown-body img { background-color: transparent; } .ui-toc-dropdown .nav>.active:focus>a, .ui-toc-dropdown .nav>.active:hover>a, .ui-toc-dropdown .nav>.active>a { color: white; border-left: 2px solid white; } .expand-toggle:hover, .expand-toggle:focus, .back-to-top:hover, .back-to-top:focus, .go-to-bottom:hover, .go-to-bottom:focus { color: white; } .ui-toc-dropdown { background-color: #333; } .ui-toc-label.btn { background-color: #191919; color: white; } .ui-toc-dropdown .nav>li>a:focus, .ui-toc-dropdown .nav>li>a:hover { color: white; border-left: 1px solid white; } .markdown-body blockquote { color: #bcbcbc; } .markdown-body table tr { background-color: #5f5f5f; } .markdown-body table tr:nth-child(2n) { background-color: #4f4f4f; } .markdown-body code, .markdown-body tt { color: #eee; background-color: rgba(230, 230, 230, 0.36); } a, .open-files-container li.selected a { color: #5EB7E0; } </style> # Git Commiter 修改方法 Tips: > 1. Target_branch must can be force push > 2. 如果已經有 "git global config" 請於推送的 repo 中新增該 repo的 "git config" > ```shell= > $ git config user.name "User Name" > $ git config user.email "User Email" > $ git config --list (顯示這個專案有的 git user 資訊,如果未設定會使用 global 做為預設的 git commiter) > $ git config user.name "cyrac7" > $ git config user.email "cyrac7@gmail.com" > ``` ## 新增 git remote 位置 ```shell= $ git remote add ${remote_name} ${remote_location} ## Example git remote add test2 git@35.75.16.184:test_group/fish_server2.git ``` ## 修改最新的 Commiter名稱 並推送到遠端特定分支 ```shell= $ git commit --amend --author="new_name <new_email>" ## Example $ git commit --amend --author="cyrac7 <cyrac7@gmail.com>" ## 推送到特定的遠端分支 $ git push ${remote_name} ${local_branch}:${target_remote_branch} --force ## Example git push test2 dev:main --force ``` ## 修改多個 Commiter 名稱 ```shell= $ git rebase -i HEAD~n $ git rebase -i ${git_Hash} (從head到該commit) ## Example $ git rebase -i HEAD~2 pick 9e79140 update readme 7 commit. pick c7329b0 update readme 8 commit. ... ... ... 1. 將 pick 更改為 edit並保存離開 $ git commit --amend --author="new_name <new_email>" 2. 再用有幾個就重複幾次(1.2)的動作 $ git rebase --continue 直到出現 Successfully rebased and updated refs/heads/dev. 在使用 $ git push ${remote_name} ${local_branch}:${target_remote_branch} --force . . . Enumerating objects: 8, done. Counting objects: 100% (8/8), done. Delta compression using up to 8 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 564 bytes | 564.00 KiB/s, done. Total 6 (delta 2), reused 0 (delta 0), pack-reused 0 To 35.75.16.184:test_group/fish_server2.git 3e81d16..e08c632 dev -> main ``` > Tips > ```shell= > ### vim 模式下可用 以下指令進行快速置換(pick >> e) > :%s/pick /e /g > ```