I started some project on github.com. And I’m working on two machines. I did something like this:
- Create project on github,
- Clone project form github on Machine1,
- Did some commits on Machine1,
- Created reposytory on Machine2,
- Push changes from Machine1 to Machine2 and github.
Next day I was working on Machine2. I have different configs there so I was doing commits with “–author=something” param. After finishing work I pushed my changes to Machine1.
I pushed my changes from Machine1 to github. And I can see that commits done on Machine1 have in history filed Author which is correct and also Committer filed which is from Machine1. And I don’t want to public this Commiter filed. How I can remove it?
Temporarily I did on Machine1:
git reset --hard <commit before changes on Machine1>
git push -f github master
But it looks like that getting committer information is still possible. How to remove it permanently.
Best regards,
Adam
If you only want to change committer information, you can use
git rebasewhich takes your commits and replays them on top of another commit. The--no-ffoption is important here, as it ensures that every commit will be recreated. Otherwise git will fast-forward in case when the rebase would be a no-op.This will quickly get tricky when your history is a bit more complex (merges), in that case it might be better to use filter-branch.
If you also want to change author information, use
git filter-branchand rewrite all of your commits with--env-filter. be sure to have a backup in case my command is flawed 😉 – though I do not hope soyou can also use
--allinstead of a refspec to rewrite all commits in your repositorynb: that’s a bad thing to do if you have shared your repository already and you will have to re-clone it on every machine you want to work with it.