1

I have a small app I've been working on, and I have two different repositories: one on my Mac machine, and one on my Windows system. Right now they should contain the same content (I just pulled from the Windows repository onto the Mac one).

Now I'd like to change the author information on all the commits in preparation for publishing.

If I do this separately on each repository, will they still be compatible, or will I have to blow one away and pull from the other one?

SilverWolf
  • 284
  • 2
  • 13
  • I suggest you just do it on one machine and get the other one to pull. Why make life more complicated? – bunbun Dec 04 '18 at 02:28
  • 1
    https://gist.github.com/masak/2415865 - author provides information how to obtain data to feed to sha1sum to compute the hash. Thus, comparing this source data should be able to answer the question. – user2864740 Dec 04 '18 at 02:35
  • @user2864740 That's very informative, thanks! So, unless I'm misunderstanding it...the answer is yes, they'll match? (Assuming the committer info matches--do I need to worry about that, or will it happen naturally with `filter-branch`?) – SilverWolf Dec 04 '18 at 02:37
  • @SilverWolf "It seems potentially legit" - if starting the the same source tree, the original commit data should already be the same. I'd give it a try :) – user2864740 Dec 04 '18 at 02:39

2 Answers2

0

Git includes various information in a commit object. All of this information is factored into the hash of the object; if any of it differs, so will the hash. Included in each commit is

  • the hash of the tree object (which depends on each tracked file and directory)
  • the hash of the preceding commit (or commits, if it's a merge)
  • the name, email, timestamp, and timezone of the author
  • the name, email, timestamp, and timezone of the committer
  • the GnuPG signature, if any
  • the commit message

Therefore, if you make changes on both machines, unless they're made at exactly the same timestamp, the hashes will differ, because the author and committer timestamps will differ.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • You can control the time stamps, so it's definitely *possible* to do this, it's just a bit hard. (Or a lot hard, depending on what else you don't know how to control :-) ) – torek Dec 04 '18 at 03:39
  • Actually, I just tried this out, and got the **same hash**. So my guess is that it doesn't affect any of the timestamp information. – SilverWolf Dec 04 '18 at 03:47
0

I just tried this out, and got the same hash both times.

My guess is that since I only changed the author information (name and email), the timestamps all stayed the same and so the hashes were identical.

SilverWolf
  • 284
  • 2
  • 13
  • If you use `git filter-branch`'s `env-filter`, note that this does the hard work of preserving as much data as possible (all of it if you change nothing). – torek Dec 04 '18 at 06:50
  • @torek Ah, I just looked and I did use `env-filter`. Very good to know, thanks! – SilverWolf Dec 04 '18 at 16:21