Skip to main content
Penyaskito Blog

Main navigation

  • Home
  • Contact
Language switcher
  • English
  • Español
User account menu
  • Log in

Breadcrumb

  1. Home

git

By penyaskito, 30 December, 2021

Rewriting history on a git repository for editing author and email on past commits

Today I needed to rewrite some git repo commits from a very recently created repository where only I had committed, but from multiple systems with different setups; my usual setup with the proper info, another one where I didn't add the global user.email git property yet, and also added the license file from gitlab itself. So basically I had three different mail addresses and two different names associated with different commits that I wanted to unify, as that's a pretty messed up history for a very recent repo.

As I found on this question on StackOverflow about git author rewriting, that can be done with git-filter-repo tool:

For installing it, I used brew (but it's available in most package managers) with just: 

brew install git-filter-repo

So then you can use it as:

git-filter-repo --name-callback 'return name.replace(b"oldName", bytes("newNameWithUtf8Chars", "utf-8"))' --email-callback 'return email.replace(b"oldmail@example.com", b"newmail@example.com")' --force

After that I had to re-add the remote and git push --force. Take into account that this rewrites history, so you (and your team) might need to reclone the repo. Please plan this accordingly.

Also take into account that if the branch is protected, you might need to add permissions for allowing to push. I allowed that temporarily following Allow force push on a protected branch on Gitlab docs.

 

Tags

  • git
By penyaskito, 24 September, 2012

Git workflow with submodules for Drupal deployment

Maybe you've seen the great article on Drupal Deployment with Git Submodules, by Randy Fay. I manage this site using that strategy, but some times I forget how every operation is done. So here I'm collecting them for my own reference.

For fetching all the new info from submodules: 

git submodule foreach git fetch origin

Now we go into each module folder and use:

git pull 

If we wanted to switch to a different branch, we should use:

git branch -a # we see the available branches 
git checkout 7.x-2.x # the different branch 

For committing it, we go back to the contrib folder and do:

git add contrib-module-name 

Then, we use:

drush updb --debug -y 

Maybe we see some warnings because of unresolved dependencies. In that case, add the new submodule:

git submodule add --branch 7.x-1.x git://git.drupal.org/project/entity.git sites/all/modules/contrib/entity 

Finally, updating core:

git merge drupal/7.x drush updb --debug -y 

Ok, so we've done this on our DEVELOPMENT site. If everything is OK, now it's time to update the server, after doing a backup:

git pull
git submodule update --init 
drush updb --debug -y

Tags

  • git
  • git submodules
  • workflow
  • Drupal
git

Monthly archive

  • December 2021 (1)
  • May 2021 (1)
  • April 2021 (1)
  • September 2014 (1)
  • November 2012 (1)
  • September 2012 (2)
  • August 2012 (3)
  • June 2012 (6)

Recent content

Rewriting history on a git repository for editing author and email on past commits
1 year 1 month ago
A Drupal JavaScript behavior for marking edited line items in the cart
1 year 8 months ago
A personal site upgrade from Drupal 7 to Drupal 9: some migration tips
1 year 9 months ago
Salesforce: generating Excel files from VisualForce APEX pages
8 years 4 months ago
Drupalcamp Spain 2012
10 years 2 months ago
Non-interactive performance tests and reporting with JMeter
10 years 4 months ago
Git workflow with submodules for Drupal deployment
10 years 4 months ago
Remoting for the Drupalcon Munich D8MI Sprint
10 years 5 months ago
Drupal Sevilla Talk: Contributing to Drupal
10 years 5 months ago
OOP & PSR-0-ify gettext .po file parsing and generation
10 years 5 months ago

Recent comments

Thanks for the comment
1 year 8 months ago
Thanks for sharing this…
1 year 8 months ago
Looking good!
1 year 9 months ago
lopd
8 years 9 months ago
LOPD
8 years 10 months ago
Gridinit
10 years 3 months ago
Ya la tiene
10 years 4 months ago
Debería :-P
10 years 4 months ago
Ei! tiene buena pinta...
10 years 4 months ago
Buenas Fco Antonio,
10 years 4 months ago

Blogs I follow

Mateu Aguiló "e0ipso"
Gábor Hojtsy
Pedro Cambra
The Russian Lullaby, davidjguru
Can It Be All So Simple
Maria Arias de Reyna "Délawen"
Matt Glaman
Josef Ottosson (dotnet)
Daniel Wehner
Jacob Rockowitz
Syndicate

Footer

  • Contact
  • Drupal.org
  • LinkedIn
  • GitHub
  • Twitter
Powered by Drupal