An Elisp API for programmatically using Git.
Add git to your Cask file:
(depends-on "git")- git-repo?
(directory) - git-branch?
(branch) - git-tag?
(tag) - git-on-branch?
(branch) - git-remote?
(name)
- git-on-branch
() - git-branches
() - git-log
(&optional branch) - git-remotes
() - git-stashes
() - git-tags
() - git-untracked-files
() - git-staged-files
()
- git-add
(&rest files) - git-branch
(branch) - git-checkout
(branch) - git-commit
(message &rest files) - git-init
(&optional dir bare) - git-remote-add
(name url) - git-remote-remove
(name) - git-reset
(&optional commit mode) - git-rm
(path) - git-stash
(&optional message) - git-stash-pop
(&optional name) - git-stash-apply
(&optional name) - git-tag
(tag)
- git-clone
(url &optional dir) - git-fetch
(&optional repo ref) - git-pull
(&optional repo ref) - git-push
(&optional repo ref)
- git-run
(command &rest args)
Return true if there is a git repo in DIRECTORY, false otherwise.
(git-repo? "/path/to/git/repo") ;; => t
(git-repo? "/path/to/svn/repo") ;; => nilReturn true if there's a branch called BRANCH.
(git-branch? "existing") ;; => t
(git-branch? "non-existing") ;; => nilReturn true if there's a tag called TAG.
(git-tag? "existing") ;; => t
(git-tag? "non-existing") ;; => nilReturn true if BRANCH is currently active.
(git-on-branch? "current") ;; => t
(git-on-branch? "other") ;; => nilReturn true if remote with NAME exists, false otherwise.
(git-remote? "existing") ;; => t
(git-remote? "non-existing") ;; => nilReturn currently active branch.
(git-on-branch) ;; => "current-branch"List all available branches.
(git-branches) ;; => '("master" "foo" "bar")Log history on BRANCH.
(git-log)
(git-log "foo")Return list of all remotes.
(git-remotes) ;; => '("remote-1" "remote-2")Return list of stashes.
(git-stashes) ;; => (:name "..." :branch "..." :message "...")Return list of all tags.
(git-tags) ;; => '("tag-1" "tag-2")Return list of untracked files.
(git-untracked-files) ;; => '("file-1" "file-2")Return list of staged files.
(git-staged-files) ;; => '("file-1" "file-2")Add PATH or everything.
(git-add)
(git-add "foo")
(git-add "foo" "bar")Create BRANCH.
(git-branch "branch")Checkout REF.
(git-checkout "branch")Commit FILES (or added files) with MESSAGE.
(git-commit "add foo" "foo")
(git-commit "add foo and bar" "foo" "bar")
(git-commit "add em all")Create new Git repo at DIR (or `git-repo').
If BARE is true, create a bare repo.
(git-init)
(git-init "foo")
(git-init "foo" :bare)Add remote with NAME and URL.
(git-remote-add "foo" "[email protected]")Remove remote with NAME.
(git-remote-remove "foo")Reset to COMMIT with MODE.
(git-reset)
(git-reset "HEAD~1" 'hard)Remove PATH.
To remove directory, use RECURSIVE argument.
(git-rm "foo")
(git-rm "bar" :recursive)Stash changes in a dirty tree with MESSAGE.
If a stash was created, the name of the stash is returned, otherwise nil is returned.
(git-stash)
(git-stash "foo")Apply and remove stash with NAME (or first stash).
(git-stash-pop)
(git-stash-pop "stash@{3}")Apply and keep stash with NAME (or first stash).
(git-stash-apply)
(git-stash-apply "stash@{3}")Create TAG.
(git-tag "tag")Clone URL to DIR (if present).
(git-clone "[email protected]")
(git-clone "[email protected]" "bar")Fetch REPO.
(git-fetch)
(git-fetch "origin" "master")Pull REF from REPO.
(git-pull)
(git-pull "origin" "master")Push REF to REPO.
(git-push)
(git-push "origin" "master")Run git COMMAND with ARGS.
(git-run "log")
(git-run "log" "--name-only")
;; ...For each command, you can add arguments using git-args.
(let ((git-args "--hard"))
(git-reset "HEAD"))Be sure to!
Install Cask if you haven't already.
Run the unit tests with:
$ make test
Do not change README.md directly. If you want to change the README
or if you change any function comments, update the README with:
$ make docs