How to Change Git User Name and Email
Easy steps to configure a Git repository and change the Git user name and email. A review of git's config object and how to retrieve information from a git repository using the git config command.
git rebase –i {{previous-commit-hash}}
pick
to edit
per each commit you want to edit. Then quit and save.git commit --amend --author="Author "
. Then, continue to next commit using: git rebase –continuegit push -f
The steps above will change the author of a commit. But what is the meaning of each commands above and what it means to change a git repository’s history?
I came across this question recently after changing the settings on GitHub page and seen that commits were logged with invalid an invalid name. Reading through Git’s documentation made it tricky to find the answer. This Stack Overflow answer nail it but I still decided to write about it to review the concepts behind scenes.
The rebase command basically integrates changes from one branch into another. It is an alternative to the “merge” command. The difference between rebase and merge is that rebase rewrites the commit history and creates a linear succession of commits, while merging adds a new commit to the destination branch. The image bellow perfectly shows a visual representation of both processes.
The amend command allows git users to change details of a commit. The amend structure is simple: git commit –amend
This will prompt a vi/vim view where the details of a git commit can be changed:
update changelog file
# Please enter the commit message for your changes. Lines starting
# with ‘#’ will be ignored, and an empty message aborts the commit.
#
# Author: Author Name < name@email.com >
# Date: Thu Jan 10 22:40:30 2020 -0300
#
# On branch some_branch
# Your branch is up-to-date with ‘origin/some_branch’.
#
# Changes to be committed:
# modified: changelog.md
It is possible to change the author of a git commit directly as seen before:git commit --amend --author="Author < email@email.com > "
Those who are familiar with rebasing know how powerful the tool it is. It might be tempting to use it all the time as well.
When getting conflicts during a rebase, Git pauses on the conflicting commit and allows to fix conflict before proceeding. However, solving conflicts in the middle of a long chain of commits is often confusing and another source of potential errors.
Rebasing creates this linear mind-set and give less priority to the actual goal of git. That is why it is not recommended to change the history of a git repository unless there is no alternative to it.
In my case, I was the only user interacting with the repository so it was safe. However, when multiple developers are working on multiple branches, change to the git history can become a real source of problems.
Easy steps to configure a Git repository and change the Git user name and email. A review of git's config object and how to retrieve information from a git repository using the git config command.
Github announced its deprecation of user passwords for all Git operations. Git operations that use authentication will require the use of token-based (GitHub User Access Token). The motivation behind this decision from GitHub is to increase user’s security from malicious attackers.
Updating Angular projects on a regular basis is very important. This article covers how to update Angular to version 11 from version 7. It also provides information about new features on Angular 11.