push - Publish local changes to remote Git repository - MATLAB (original) (raw)
Publish local changes to remote Git repository
Since R2023b
Syntax
Description
push([repo](#mw%5Fc9999337-b27f-4a3e-9121-e29bcb70f516))
publishes changes in the current branch of the local Gitâ„¢ repository repo
to the remote repository. Use this syntax to push branches that already have configured remotes, such as the main
branch.
push([repo](#mw%5Fc9999337-b27f-4a3e-9121-e29bcb70f516),[Name=Value](#namevaluepairarguments))
specifies additional options as one or more name-value arguments.
Examples
Navigate to your repository folder and create a repository object.
Switch to the newFeature
branch that you want to push to the remote repository.
switchBranch(repo,"newFeature");
Push local changes on the current branch to the remote repository.
Navigate to your repository folder and create a repository object.
Switch to the newFeature
branch that you want to push to the remote repository.
switchBranch(repo,"newFeature");
Push local changes on the current branch to the remote repository.
To push the changes from a local branch that does not have a configured remote, specify the Remote
argument.
The function creates an upstream branch named origin/newFeature
in the remote repository. The local branch newFeature
tracks the upstream remote branch origin/newFeature
.
push(repo,Remote="origin");
To push the changes on the current branch to a remote branch that has a different name, specify the RemoteBranch
argument. The local branchnewFeature
tracks the upstream remote branchorigin/betterName
.
The function creates an upstream branch namedorigin/betterName
.
push(repo,Remote="origin",RemoteBranch="betterName");
To push the changes to a passphrase-protected remote repository, specify theUsername
and Token
arguments.
secrets = loadenv("github.env"); push(repo,Username=secrets("GITHUB_USER"),Token=secrets("GITHUB_TOKEN"),Remote="origin",RemoteBranch="betterName");
Input Arguments
Name-Value Arguments
Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN
, where Name
is the argument name and Value
is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.
Example: push(repo,Remote="origin",RemoteBranch="myNewTask")
Username for the Git repository account, specified as a character vector or string scalar.
Data Types: char
| string
Personal access token for the Git repository account, specified as a character vector or string scalar.
Data Types: char
| string
Name of the remote to which the function publishes data, specified as a character vector or string scalar.
Data Types: char
| string
Name of the remote branch to which the function publishes data, specified as a character vector or string scalar. If you do not specify this input, the function uses the local branch name to create the remote branch. The local branch tracks the upstream remote branch that the function creates.
Data Types: char
| string
Version History
Introduced in R2023b