Represents the underlying git operations performed by Atom.
This class shouldn’t be instantiated directly but instead by accessing the
atom.project
global and calling getRepositories()
. Note that this will
only be available when the project is backed by a Git repository.
This class handles submodules automatically by taking a path
argument to many
of the methods. This path
argument will determine which underlying
repository is used.
For a repository with submodules this would have the following outcome:
repo = atom.project.getRepositories()[0]
repo.getShortHead() # 'master'
repo.getShortHead('vendor/path/to/a/submodule') # 'dead1234'
git = atom.project.getRepositories()[0]
console.log git.getOriginURL()
[GitRepository](../GitRepository/) = require 'atom'
Creates a new GitRepository instance.
Argument | Description |
---|---|
|
The String path to the Git repository to open. |
|
An optional Object with the following keys: |
|
A Boolean, |
Return values |
---|
Returns a GitRepository instance or |
Destroy this GitRepository object.
This destroys any tasks and subscriptions and releases the underlying libgit2 repository handle. This method is idempotent.
Invoke the given callback when this GitRepository’s destroy() method is invoked.
Argument | Description |
---|---|
|
Return values |
---|
Returns a Disposable on which |
Invoke the given callback when a specific file’s status has changed. When a file is updated, reloaded, etc, and the status changes, this will be fired.
Argument | Description |
---|---|
|
|
|
|
|
String the old parameters the decoration used to have |
|
Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information. |
Return values |
---|
Returns a Disposable on which |
Invoke the given callback when a multiple files’ statuses have changed. For example, on window focus, the status of all the paths in the repo is checked. If any of them have changed, this will be fired. Call ::getPathStatus to get the status for your path of choice.
Argument | Description |
---|---|
|
Return values |
---|
Returns a Disposable on which |
A String indicating the type of version control system used by this repository.
Return values |
---|
Returns |
Return values |
---|
Returns true if at the root, false if in a subfolder of the repository. |
Makes a path relative to the repository’s working directory.
Return values |
---|
Returns true if the given branch exists. |
Retrieves a shortened version of the HEAD reference value.
This removes the leading segments of refs/heads
, refs/tags
, or
refs/remotes
. It also shortens the SHA-1 of a detached HEAD
to 7
characters.
Argument | Description |
---|---|
|
An optional String path in the repository to get this information for, only needed if the repository contains submodules. |
Return values |
---|
Returns a String. |
Argument | Description |
---|---|
|
optional
String path in the repository to get this information for, only needed if the repository has submodules. |
Return values |
---|
Returns the origin url of the repository. |
Argument | Description |
---|---|
|
An optional String path in the repo to get this information for, only needed if the repository contains submodules. |
Return values |
---|
Returns the upstream branch for the current HEAD, or null if there is no upstream branch for the current HEAD. |
Returns a String branch name such as |
Get the status of a directory in the repository’s working directory.
Argument | Description |
---|---|
|
The String path to check. |
Return values |
---|
Returns a Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information. |
Get the status of a single path in the repository.
Argument | Description |
---|---|
|
A String repository-relative path. |
Return values |
---|
Returns a Number representing the status. This value can be passed to ::isStatusModified or ::isStatusNew to get more information. |
Restore the contents of a path in the working directory and index
to the version at HEAD
.
This is essentially the same as running:
git reset HEAD -- <path>
git checkout HEAD -- <path>
Argument | Description |
---|---|
|
The String path to checkout. |
Return values |
---|
Returns a Boolean that’s true if the method was successful. |