Git

How to Fix “Git author Unknown” Error?

While working on Git, developers commit to save changes to the local repository. Sometimes, they get the “Git author Unknown” error while commenting on Git. This error occurs when the author’s information has not been added to the Git configuration file. In order to make commits, it is required to add the username and email.

This study will explain:

How to Fix “Git author Unknown” Error Using Command Line?

To fix the “Git author Unknown” error using the command line, first, redirect to the local Git repository. Then, check the Git configuration setting to ensure whether the user information has been set or not. If the user information is not added, then set the user name and email in the configuration file by utilizing the “git config –global user.email “<name>”” and “git config –global user.email “<email>”” commands.

Step 1: Redirect to Local Directory

First, switch to the particular repository by utilizing the following command:

$ cd "C:\Git\RepoZ"

Step 2: Generate a New File

Execute the provided command to generate an empty file in the Git working directory:

$ touch demo.txt

Step 3: Track Changes

Then, add the newly created file to the Git staging area using the below-given command:

$ git add demo.txt

Step 4: Commit Changes

To save added changes in the repository, execute the “git commit” command along with the desired commit message:

$ git commit -m "demo file added"

In the below screenshot, it can be seen that there is an error that says “Author identity unknown”:

To resolve the above-stated error, try out the next steps.

Step 5: Check Username

Execute the following command to check if the username is globally set or not:

$ git config --global user.name

No output signifies that the username is not added previously:

Step 6: Check User Email

To ensure whether the user email has been set or not, type out the following command:

$ git config --global user.email

As you can see, the value of the email address is empty by default:

Step 7: Set Username

Now, change the configuration setting, and add the username with the help of the below-provided command:

$ git config --global user.name "Laiba Younas"

Here, the “–global” option is used to set the username globally, which means that all repositories that exist in the Git root directory can utilize it:

Step 8: Set User Email

Similarly, set the desired user email address by executing the following command:

$ git config --global user.email "[email protected]"

Step 9: Verify Username

Next, use the below-stated command to ensure that the newly added username exists or not:

$ git config --global user.name

Step 10: Verify User Email

Then, verify whether the previously specified user email address has been set or not:

$ git config --global user.email

Step 11: Commit Changes

Lastly, run the “git commit” command to save all the staged changes in the Git current working repository:

$ git commit -m "demo file added"

According to the below output, the changes have been committed successfully and the error has been resolved:

How to Fix “Git author Unknown” Error Manually?

To fix the “Git author Unknown” error manually, follow the provided path on your PC and open the “.gitconfig” file in the text editor:

C:\Users\username\.gitconfig

According to the below-given output, the “user” information is missing from the Git default settings:

Now, specify the desired username and email address in the required sections and press the “CTRL + S” keys to save changes:

We have explained the easiest solutions to resolve the “Git author Unknown” Error.

Conclusion

To fix the “Git author Unknown” error, check the Git configuration setting to see whether the username and email have been set or not. If the user information is not added, then set the username and information in the configuration setting using the “git config –global user.email “<name>”” and “git config –global user.email “<email>”” commands, or follow the “C:\Users\username\.gitconfig” path in the PC and add the author information in the “.gitconfig” file. This study provided the solutions to fix the “Git author Unknown” error.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.