0

Let's say you have been working on a branch. You decide that you want to git stash your changes and continue working on something else. Later when you checkout on your branch to unstash your stashed work and commit it, what date will be shown in the commit history after you make a push?

Will the date be the time of stashing or the time of the actual commit of the unstashed files?

4
  • 2
    It should alway be the time you authored the commit, not the stash. Have you tested it out to see? Commented Oct 28, 2018 at 20:31
  • 2
    Once you unstash you're back to vanilla staged/unstaged changes. Commented Oct 28, 2018 at 20:33
  • Thanks! @evolutionxbox @Oliver Charliesworth Does this also refer to shelve changes? I know this functionality is IDE specific and not part of git, but is it the same as it is with stashing / unstashing changes? Commented Oct 28, 2018 at 20:36
  • Sadly I don’t know. I’m not a fan of how IDEs use other VCS names for git. Commented Oct 28, 2018 at 20:38

1 Answer 1

1

When you git commit changes, Git has no notion of where those changes came from. Whether you modified the files in an editor, copied them in, or they got there from git stash pop, Git has no idea. Accordingly, the commit’s commit/author timestamp is wholly unaffected by the timestamp of the stash.

To change the commit timestamp to be something other than the current system time, something would have to set the GIT_COMMITTER_DATE environment variable. The author timestamp can be set by passing --date or -C/--reuse-message to git commit, or by setting GIT_AUTHOR_DATE.

Sign up to request clarification or add additional context in comments.

Comments