Support for the Git SCM
add a file to git
CLI Example:
salt '*' git.add /path/to/git/repo /path/to/file
Export a tarball from the repository
If prefix is not specified it defaults to the basename of the repo directory.
CLI Example:
salt '*' git.archive /path/to/repo /path/to/archive.tar.gz
Interacts with branches.
CLI Example:
salt '*' git.branch mybranch --set-upstream-to=origin/mybranch
Checkout a given revision
CLI Examples:
salt '*' git.checkout /path/to/repo somebranch user=jeff
salt '*' git.checkout /path/to/repo opts='testbranch -- conf/file1 file2'
salt '*' git.checkout /path/to/repo rev=origin/mybranch opts=--track
Clone a new repository
HTTP Basic Auth username for HTTPS (only) clones
New in version 20515.5.0.
HTTP Basic Auth password for HTTPS (only) clones
New in version 2015.5.0.
CLI Example:
salt '*' git.clone /path/to/repo git://github.com/saltstack/salt.git
salt '*' git.clone /path/to/repo.git\
git://github.com/saltstack/salt.git '--bare --origin github'
create a commit
CLI Example:
salt '*' git.commit /path/to/git/repo 'The commit message'
Get a key or keys from the git configuration file (.git/config).
Optional path to a Git repository
Changed in version 2014.7.0: Made cwd optional
CLI Example:
salt '*' git.config_get setting_name=user.email
salt '*' git.config_get /path/to/repo user.name arthur
Set a key in the git configuration file (.git/config) of the repository or globally.
Options path to the Git repository
Changed in version 2014.7.0: Made cwd optional
CLI Example:
salt '*' git.config_set /path/to/repo user.email me@example.com
Returns the current branch name, if on a branch.
CLI Example:
salt '*' git.current_branch /path/to/repo
Returns the git describe string (or the SHA hash if there are no tags) for the given revision
CLI Examples:
salt '*' git.describe /path/to/repo
salt '*' git.describe /path/to/repo develop
Perform a fetch on the given repository
CLI Example:
salt '*' git.fetch /path/to/repo '--all'
salt '*' git.fetch cwd=/path/to/repo opts='--all' user=johnny
Initialize a new git repository
CLI Example:
salt '*' git.init /path/to/repo.git opts='--bare'
Returns the upstream hash for any given URL and branch.
HTTP Basic Auth username for HTTPS (only) clones
New in version 2015.5.0.
HTTP Basic Auth password for HTTPS (only) clones
New in version 2015.5.0.
CLI Example:
salt '*' git.ls_remote /pat/to/repo origin master
Merge a given branch
CLI Example:
salt '*' git.fetch /path/to/repo
salt '*' git.merge /path/to/repo @{upstream}
Perform a pull on the given repository
CLI Example:
salt '*' git.pull /path/to/repo opts='--rebase origin master'
Push to remote
CLI Example:
salt '*' git.push /path/to/git/repo remote-name
Rebase the current branch
CLI Example:
salt '*' git.rebase /path/to/repo master
salt '*' git.rebase /path/to/repo 'origin master'
That is the same as:
git rebase master
git rebase origin master
get the fetch and push URL for a specified remote name
CLI Example:
salt '*' git.remote_get /path/to/repo
salt '*' git.remote_get /path/to/repo upstream
sets a remote with name and URL like git remote add <remote_name> <remote_url>
HTTP Basic Auth username for HTTPS (only) clones
New in version 2015.5.0.
HTTP Basic Auth password for HTTPS (only) clones
New in version 2015.5.0.
CLI Example:
salt '*' git.remote_set /path/to/repo remote_url=git@github.com:saltstack/salt.git
salt '*' git.remote_set /path/to/repo origin git@github.com:saltstack/salt.git
Get remotes like git remote -v
CLI Example:
salt '*' git.remotes /path/to/repo
Reset the repository checkout
CLI Example:
salt '*' git.reset /path/to/repo master
Returns the long hash of a given identifier (hash, branch, tag, HEAD, etc)
CLI Example:
salt '*' git.revision /path/to/repo mybranch
Remove a file from git
CLI Example:
salt '*' git.rm /path/to/git/repo /path/to/file
Stash changes in the repository checkout
CLI Example:
salt '*' git.stash /path/to/repo master
Return the status of the repository. The returned format uses the status codes of git's 'porcelain' output mode
CLI Example:
salt '*' git.status /path/to/git/repo
Initialize git submodules
CLI Example:
salt '*' git.submodule /path/to/repo.git/sub/repo
Docs for previous releases are available on readthedocs.org.
Latest Salt release: 2015.5.2