# Successfully rebased and updated refs/heads/master. # continue running the last two commands until you see # edit the file to read "edit for each entry Git checkout and rebase it onto your new root commit This effectively replaces the last commit with your 'edited' version, correcting the wrong author information. # now you've changed the commit message, so checkout the original branch again In case you want to change just the very last commit, Git offers a very easy way to do this: git commit -amend -author'John Doe <>'.Git commit -amend -author "Foo (or if you've set the proper git **config** values) # check it out on its own temporary branch Git tag root `git rev-list HEAD | tail -1` # create a temporary tag for the root-most commit so we can reference it Git reset -hard $BRANCH2 # be careful with this commandĬombining the answer from How do I fix the metainformation on the first commit in git? # Fix the first commit # The original branch ref can be reassigned to the new one, and the new one deleted: git checkout $BRANCH mapfile and do: git checkout -b $BRANCH2 $START ![]() So when you need to correct authors, now you just then need to generate a. Reauthor = !sh -c 'eval `git log -reverse -topo-order -pretty=format:\"git cherry-pick %H & git commit -amend -C %H -author=\\\"%aN \\\" & \" $0 ` "echo success" ' This is also generally applicable - put this in your ~/.gitconfig: For each commit between $START and then end of $BRANCH, the second command cherry picks the original commit on to the end of the current branch $BRANCH2, and amends it to set the author correctly. The first command creates a new empty branch sprouting from the commit $START. Git log -reverse -pretty=format:"cherry-pick %H commit -amend -author='%aN ' -C %H" $START.$BRANCH | sh. ![]() mailmap file like this (say): You you can use git log's formatting feature to generate the commands to rewrite $BRANCH as $BRANCH2. You can get a list of the existing author names with: git shortlog -se mailmap file in the top directory of your repository which maps the existing author names to he correct ones. We can use it to generate the commands to pick and amend amend a named sequence of commits.įor example, suppose you want to correct the authorship on a branch $BRANCH, starting at a commit $START. This provides an author mapping mechanism we can use with git log's formatting facility. mailmap feature described in the git-shortlog manpage. Here's an alternative I found useful, which uses the. You can suppress this message by setting them explicitly.Git's filter-branch command is powerful, but it's horribly unwieldy to use for anything non-trivial, like for example, if you have more than one author to correct. Your name and email address were configured automatically based on your username and hostname. The old advice is kept if the user already has a configuration file since the template feature would not trigger in this case. When the user has no user-wide configuration file, it's faster to use the newly introduced config file template than to run two commands to set user.name and user.email. Note that the user.name and email are guessed and put in that /.gitconfig file, as per commit 8b27ff7: commit: advertise config -global -edit on guessed identity ![]() If you put your GitHub username and email account in those settings, your commits will accurately reflect your GitHub account as the right author. If the values are guessed properly, the user will only have to uncomment the entries.Īdvanced users teaching newbies can create a minimalistic configuration faster for newbies.īeginners reading a tutorial advising to run " git config -global -edit" as a first step will be slightly more guided for their first contact with Git. The template contains only commented-out entries, to save a few keystrokes for the user. ![]() Instead, create a file with a default content before launching the To launch an editor on an nonexistant file name. When the user has no ~/.gitconfig file, git config -global -edit used Note that starting Git 2.2 (Q3/Q4 2014), and commit 9830534 by Matthieu Moy ( moy), you will be naturally guided to enter a user and email: config -global -edit: create a template file if needed
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |