Skip to content

Command: git submit

kain88-de edited this page May 4, 2024 · 12 revisions

Description

Available since v0.5.0.

The git submit command lets you push a set of branches to a remote all at once. This is useful for workflows involving centralized Git hosting providers, such as GitHub and GitLab, where you must push a branch in order to open a pull request/merge request.

git submit can create code reviews for some Git hosting providers; see Forges.

To update your local work on top of the remote main branch, see git sync. If your own commit was merged into the remote main branch, then git sync will automatically clean it up for you locally.

Usage

When run with no arguments, git submit will force-push all branches in your current commit stack which already exist on the remote. This is meant as a shorthand to update your entire commit stack at once, useful if you've made changes to a commit earlier in the stack or if you've rebased your stack recently.

Note that force-pushing branches will overwrite public history. This is generally only recommended for branches which are under review, which no one else is using; people using your branch would have merge conflicts if they tried to pull it.

To submit a different set of branches, pass a revset expression as the argument. For example, to submit only branches pointing to the current commit, run:

$ git submit @

Or to submit all of your local branches, run:

$ git submit 'draft()'

Creating a new remote branch

By default, git submit does not push branches which haven't been pushed to the remote before. This is to ensure that you don't publish work that's not ready yet, and that you don't clobber an existing branch on the remote with the same name.

To push a new branch to the remote, run git submit with the -c/--create option. (You will have to create the branch first, such as with git branch <name> <target> or git switch --create <name> <target> or git record with the --create option.)

To specify which remote should be pushed to with git submit --create, configure the remote.pushDefault option:

$ git config remote.pushDefault origin

This is particularly useful if your repository has different "pull" and "push" remotes, which is commonly the case when working with repository forks.

Forges

A "forge" is a Git hosting provider, usually including a code review system. If a forge is selected or detected, git submit will also create code reviews associated with the submitted commits as appropriate for the forge.

The default value for the --forge option is branch, which indicates to push branches without creating any code reviews. It is suitable for any Git hosting provider that lets you push branches.

Phabricator

You can select the Phabricator forge by passing --forge phabricator.

If no --forge option is passed and an .arcconfig file is present in the repository root, then git submit will automatically select phabricator. To create code reviews, git submit will run arc diff on each commit and set the stack dependencies appropriately.

Clone this wiki locally