diff --git a/README.md b/README.md index b13203b6..709d5741 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,9 @@ g.push(g.remote('name')) # delete remote branch g.push('origin', 'remote_branch_name', force: true, delete: true) +# push all branches to remote at one time +g.push('origin', all: true) + g.worktree('/tmp/new_worktree').add g.worktree('/tmp/new_worktree', 'branch1').add g.worktree('/tmp/new_worktree').remove diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 86c34a85..06f3a2a1 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -972,7 +972,9 @@ def push(remote = nil, branch = nil, opts = nil) arr_opts = [] arr_opts << '--mirror' if opts[:mirror] arr_opts << '--delete' if opts[:delete] - arr_opts << '--force' if opts[:force] || opts[:f] + arr_opts << '--force' if opts[:force] || opts[:f] + arr_opts << '--all' if opts[:all] && remote + Array(opts[:push_option]).each { |o| arr_opts << '--push-option' << o } if opts[:push_option] arr_opts << remote if remote arr_opts_with_branch = arr_opts.dup diff --git a/tests/units/test_push.rb b/tests/units/test_push.rb index df030381..83c227b7 100644 --- a/tests/units/test_push.rb +++ b/tests/units/test_push.rb @@ -96,6 +96,13 @@ class TestPush < Test::Unit::TestCase assert_command_line(expected_command_line, git_cmd, git_cmd_args) end + test 'push with all: true' do + expected_command_line = ['push', '--all', 'origin'] + git_cmd = :push + git_cmd_args = ['origin', all: true] + assert_command_line(expected_command_line, git_cmd, git_cmd_args) + end + test 'when push succeeds an error should not be raised' do in_temp_dir do Git.init('remote.git', initial_branch: 'master', bare: true)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: