Reputation: 9803
This issue really threw me off and my searches didn't turn up any helpful info so I'm posting this to help any other poor soul who runs into this.
I was working on an Android repository today and made a number of commits and merges and all the regular stuff.
I noticed at one point that a commit listed under a ticket on our git server has a date of 8 days ago. The commit was not eight days old, I had created it from scratch and pushed it to the ticket less than 15 minutes before.
I thought, this is strange and wondered if the server time was wrong. Having confirmed it wasn't, I looked at the commits more closely. The dates all looked fine in SourceTree (a git gui I use). Knowing that a commit can have a separately set authoring date, I used git log --pretty=fuller
to view and compare the dates.
C:\Users\Jonathan\StudioProjects\BTVehicle>git log --pretty=fuller -n 2
commit 29ee84b938c016ff747d088c9c8d038f5ed99e72
Merge: f462490 7a76ac3
Author: Jonathan
AuthorDate: Wed May 25 16:19:18 2016 -0500
Commit: Jonathan
CommitDate: Wed May 25 16:19:18 2016 -0500
Merged #416 "CursorIndexOutOfBoundsException: Index 1 requested, with a size of 1"
commit 7a76ac3903380d7e1bde693947da84cab328cc7a
Author: Jonathan
AuthorDate: Tue May 17 12:55:07 2016 -0500
Commit: Jonathan
CommitDate: Wed May 25 16:19:14 2016 -0500
Added what could be a fix for the CursorIndexOutOfBoundsException as described in ticket #416.
The merge commit above was done on my server. The times are accurate. The other was done on my local machine (via Android Studio's source control integration) and has an incorrect authorship time.
How did this happen? How can I fix future dates? My findings are below.
Upvotes: 2
Views: 934
Reputation: 9803
Cherry-Picking in the Android Studio IDE created a change list which, while active, causes any commits to have an author date equal to the original cherry-picked commit.
The issue started when I cherry-picked commits in Android Studio earlier today.
If you use the VCS Log to select a commit to cherry-pick in Android studio, the commit dialog will be brought up so you can review the changes before making the commit. If you then commit the changed from that dialog, you will have no issues.
If, however, you cancel out of the commit dialog (because you want to make changes before committing or any other reason), A new change list will be created and will contain the files changed in the cherry-pick.
Simultaneously, the IDE will complain that a file from a non-active changelist is modified. So I switched to the cherry-pick changeset.
Now, when you open the commit changes dialog, the Author is set in the upper-right hand corner. There is no mention of time though. What I've found is that this field is actually usually blank.
What I found was any commits made while this cherry-pick change list is active will have the incorrect author date set. The solution is to simply change to a different or new change list in Android Studio.
I decided in my case that the incorrect author dates on a few of my commits was simply an inconvenience and not worth the time or effort of fixing. This was especially the case since I had already pushed a bunch of changed and didn't want to have to rewind a bunch of stuff.
But for those who just need to change the date on their last commit or want more information, this page has some nice instructions on ammending dates.
Upvotes: 2