Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Git is a distributed version control system, so you have to carefully define what you mean by "push date". For example, suppose user A pushes some commits to user B's repository. Some point later, user B pushes those same commits to a third repository. Which date are you interested in?</p> <p>I'm speculating that you have a shared repository and want the users of that shared repository to be able to determine when something was published to the repository. If that's true, you'll have to collect that information in the shared repository.</p> <h3>The bad news</h3> <p>Unfortunately, there's no way to append the date to the commit messages. That would change the commit ID (which is a SHA1 hash of the contents), causing all sorts of problems.</p> <h3>The good news</h3> <p>Fortunately, Git has a (relatively new) feature called <em>notes</em>. This feature allows you to attach arbitrary text to commits, which <code>git log</code> can display. Notes can be edited and shared with others.</p> <p>You can use the notes feature to attach a "this commit was received on [date]" message to each commit as it is received by the shared repository.</p> <p>See <code>git help notes</code> for details.</p> <h3>How to record the date</h3> <p>Here's the approach I recommend:</p> <ol> <li>Modify the <code>post-receive</code> hook on your shared repository to walk each newly reachable commit for each updated reference.</li> <li><p>For each commit, append something like "[user] of [repository_url] added this commit to [ref] on [date]" to the commit's note.</p> <p>You may want to use a notes ref dedicated to this purpose (like <code>refs/notes/received-on</code>) instead of the default <code>refs/notes/commits</code>. This will prevent conflicts with notes created for other purposes.</p></li> <li>Modify your <code>receive</code> hook to deny updates to your notes reference (to keep users from accidentally or purposely messing with the notes).</li> <li><p>Tell all the users to run the following commands from inside their working tree:</p> <pre><code># Fetch all notes from the shared repository. # Assumes the shared repository remote is named 'origin'. git config --add remote.origin.fetch '+refs/notes/*:refs/remote-notes/origin/*' # Show all notes from the shared repository when running 'git log' git config --add notes.displayRef 'refs/remote-notes/origin/*' </code></pre> <p>This step is necessary because Git ignores non-branch, non-tag references in upstream repositories by default.</p></li> </ol> <p>The above assumes that references are only advanced, never deleted or force-updated. You'll probably want to have the <code>post-receive</code> hook also append "removed on [date]" notes to handle these cases.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload