Module: Git::Commands::UpdateRef Private

Defined in:
lib/git/commands/update_ref.rb,
lib/git/commands/update_ref/batch.rb,
lib/git/commands/update_ref/delete.rb,
lib/git/commands/update_ref/update.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Commands for safely updating ref values via git update-ref

This module contains command classes split by invocation mode:

  • Update — set a ref to a new value (the default mode); also supports verifying the old value before updating
  • Delete — delete a ref (-d flag); optionally verifies the current value before deleting
  • Batch — read update/create/delete/verify instructions from stdin (--stdin); all modifications are applied atomically

Examples:

Update a branch ref to a new commit SHA

cmd = Git::Commands::UpdateRef::Update.new(lib)
cmd.call('refs/heads/main', 'abc1234')

Delete a ref

cmd = Git::Commands::UpdateRef::Delete.new(lib)
cmd.call('refs/heads/old-branch')

Atomically update multiple refs via stdin

cmd = Git::Commands::UpdateRef::Batch.new(execution_context)
cmd.call(
  'update refs/heads/main newsha oldsha',
  'delete refs/heads/old'
)

See Also:

Defined Under Namespace

Classes: Batch, Delete, Update