push
Description
push(
publishes changes in the current
branch of the local Git™ repository repo
)repo
to the remote repository. Use this syntax
to push branches that already have configured remotes, such as the main
branch.
push(
specifies additional options as one or more name-value arguments.repo
,Name=Value
)
Examples
Push Local Changes to Remote
Navigate to your repository folder and create a repository object.
repo = gitrepo;
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.
push(repo);
Push Local Changes to Remote With Additional Options
Navigate to your repository folder and create a repository object.
repo = gitrepo;
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.
push(repo);
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.
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 function creates an upstream branch named
origin/betterName
.
push(repo,Remote="origin",RemoteBranch="betterName");
To push the changes to a passphrase-protected remote repository, specify the
Username
and Token
arguments.
secrets = loadenv("github.env"); push(repo,Username=secrets("GITHUB_USER"),Token=secrets("GITHUB_TOKEN"),Remote="origin",RemoteBranch="betterName");
Input Arguments
repo
— Git repository
matlab.git.GitRepository
object
Git repository, specified as a matlab.git.GitRepository
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=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
— Username for Git repository account
character vector | string scalar
Username for the Git repository account, specified as a character vector or string scalar.
Data Types: char
| string
Token
— Personal access token for Git repository account
character vector | string scalar
Personal access token for the Git repository account, specified as a character vector or string scalar.
Data Types: char
| string
Remote
— Remote name
character vector | string scalar
Name of the remote to which the function publishes data, specified as a character vector or string scalar.
Data Types: char
| string
RemoteBranch
— Remote branch name
character vector | string scalar
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.
Data Types: char
| string
Version History
Introduced in R2023b
See Also
gitclone
| gitrepo
| commit
| createBranch
| switchBranch
| fetch
| merge
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)