Recently, when I was working on my own project , Due to the use of git Globally configured user name and mailbox , All submitted records in your own private warehouse use the company's email and user name , So I want to replace it in batch .

You can use the following command under the root directory of the project to be modified , Batch replacement :

git filter-branch -f --env-filter \
"GIT_AUTHOR_NAME='freephp'; GIT_AUTHOR_EMAIL='[email protected]';" HEAD

Then force it to be pushed to the remote server :

git push origin -f branch_name

After that, localize the project and configure the user name and mailbox , The order is as follows :

git config user.username "freephp"
git config user.email "[email protected]"

Submit after that , The user name and mailbox in the submission information are newly set .

Reuse git log command , You can see the newly submitted submission record as follows :

commit f237a55237ecceb7f837bae0bedde2b927451a07
Author: freephp
<[email protected]>
Date: Wed Sep 29 19:06:19 2021 +0800 Change some logic and fix updates bug

To sum up , If there are multiple projects of different organizations ( company 、 personal 、 Open source ), Local settings need to be set separately in the project of each organization , Avoid information confusion caused by global configuration . Of course, batch processing is also a good remedy , Relevant commands are very practical .

git Batch processing git author and commit More articles about

  1. git Batch modify submitted commit Your name and email address

    First , We created change.sh Script , And copy the following script based on personal information . #!/bin/sh git filter-branch --env-filter ' OLD_EMAIL=" Fill in the original email ...

  2. Git Batch deletion

    Git Batch deletion git All of the changes need to be stage Only after the process can commit. When git When there are a lot of changes in, you need to be able to batch operate in convenient . There are three kinds of changes : modify: There are file changes add: There are documents added rm: There are file deletions ...

  3. git Batch delete files and batch submit

    1. Single delete file : ① Usually, the useless files are deleted directly in the file manager , Or use rm The order deleted :( Optional operation , It can be executed directly ② Delete ) $ rm test.txt ② Are you sure you want to remove this file from the repository , Then by order git rm ...

  4. git Use a drop : How to view commit The content of

    stay push Before, sometimes I don't know if I forget to add some documents , Or did you delete something more , At this time, I hope to see last time commit What has been done . At first I thought of using Git diff, however git diff Used for the current modification c ...

  5. git Batch delete folders and files

    git  Batch delete folders and files After deleting files from the hard disk , perform $ git status   It will remind you that you still need $ git rm < file >   At this time, if you want to delete a large number of files , It's very tiring to go on such an order ...

  6. Git Study --&gt; Personal common commands add,commit as well as push

    Git Command line configuration 1 install Github2 install msysgit3 To configure the user name and fuel tank   git config --global user.name < user name >  My order is :git confi ...

  7. Use git Batch delete branches

    To delete a local , First of all, consider the following three points List all local branches Search for target branches such as : All contain ‘dev’ The branch of Pass the search results to the delete function So we can get : git br |grep 'dev' |xargs git ...

  8. git Merge specified on branch commit

    merge Able to meet most of the usual consolidation needs . But there are some special situations , For example, a new feature is being developed , The line says there is an urgent bug To fix it .bug It's fixed, but it's not like submitting the new function code still under development to the line . At this time, you may want to ...

  9. Git Misoperation git reset Force rollback recovery commit Method

    Reference resources : Retrieve Git What's lost in Commit Git Misoperation git reset Force rollback recovery commit Method Use Git when , There are often misoperations , stay Commit And then it was executed git reset --hard HEAD strong ...

  10. Git Submit the correct posture :Commit message Write a guide

    http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html Git Every time code is submitted , Write everything Commit message( ...

Random recommendation

  1. HTML5 The new way

    json The new way : parse()   take JSON Convert to string : Must be strict JSON Format : usage : var s = {"name":"name"}; JSO ...

  2. Webpage qq Customer service code and custom image

    <script>var online= new Array();</script> <script src="http://webpresence.qq.com ...

  3. RobotFramework - Tips

    1 --- API Use Robot Framework The development of the new version is downward inclusive , It is recommended to use robot Of itself API. for example : By importing logger.py(...\Lib\site-packages\rob ...

  4. cocos2d-x Tips

    1. character string And Data structures are transferred to each other CCPoint: CCPointFromString(); {x, y} CCSize: CCSizeFromString(); {w, h} CCRect: CCSiz ...

  5. Swift Expand (Extension)

    Based on the types of existing classes and structs , Expand new features . grammar : extension SomeType{ // new functionality to add to SomeType goes here } A ...

  6. .Net Core And MSBuild Introduce

    Preface About .NET Core The old version of sdk For an introduction, please refer to my previous This article article . 8 An hour ago ,.NET Core The project team released .NET Core A new round of sdk Tool update , namely RC4 edition ...

  7. ES6 Focus on the core content -- Fast practice ES6( One )

    Preface This article makes a lot of reference to Mr. Ruan Yifeng's open source tutorial ECMAScript6 introduction , Suitable for beginners or for ES6 A comprehensive review of common knowledge points , The goal is to cover... In less space ES6 And part of ES7 Most usage scenarios in practice . More comprehensive . Deeper ...

  8. P2774 How to get the number of squares ( Network flow )

    P2774 How to get the number of squares emm........ Take a closer look. , Isn't this the problem of maximal weighted closed subgraph ! Take a point $(x,y)$, The restriction is to take... At the same time $(x,y+1),(x,y-1),(x+1,y),(x-1,y)$, Just not ...

  9. Windows In the environment jenkins Continuous integration

    A server as a code repository , A server for continuous integration code warehouse is currently common github.gitlab.gitee Continuous integration is commonly used Jenkins The configuration of the server is as follows Windows For example 1. install Jenkins ...

  10. English ( One )

    Phrase        do somebody a favour give sb a hand do something for sb come to sb aid  Help sb what can ...