Skip to content

rejeep/git.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git.el

An Elisp API for programmatically using Git.

Installation

Add git to your Cask file:

(depends-on "git")

API

Predicates

Info

Destructive

Non local

Misc

Documentation and examples

git-repo? (directory)

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") ;; => nil

git-branch? (branch)

Return true if there's a branch called BRANCH.

(git-branch? "existing") ;; => t
(git-branch? "non-existing") ;; => nil

git-tag? (tag)

Return true if there's a tag called TAG.

(git-tag? "existing") ;; => t
(git-tag? "non-existing") ;; => nil

git-on-branch? (branch)

Return true if BRANCH is currently active.

(git-on-branch? "current") ;; => t
(git-on-branch? "other") ;; => nil

git-remote? (name)

Return true if remote with NAME exists, false otherwise.

(git-remote? "existing") ;; => t
(git-remote? "non-existing") ;; => nil

git-on-branch ()

Return currently active branch.

(git-on-branch) ;; => "current-branch"

git-branches ()

List all available branches.

(git-branches) ;; => '("master" "foo" "bar")

git-log (&optional branch)

Log history on BRANCH.

(git-log)
(git-log "foo")

git-remotes ()

Return list of all remotes.

(git-remotes) ;; => '("remote-1" "remote-2")

git-stashes ()

Return list of stashes.

(git-stashes) ;; => (:name "..." :branch "..." :message "...")

git-tags ()

Return list of all tags.

(git-tags) ;; => '("tag-1" "tag-2")

git-untracked-files ()

Return list of untracked files.

(git-untracked-files) ;; => '("file-1" "file-2")

git-staged-files ()

Return list of staged files.

(git-staged-files) ;; => '("file-1" "file-2")

git-add (&rest files)

Add PATH or everything.

(git-add)
(git-add "foo")
(git-add "foo" "bar")

git-branch (branch)

Create BRANCH.

(git-branch "branch")

git-checkout (branch)

Checkout REF.

(git-checkout "branch")

git-commit (message &rest files)

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")

git-init (&optional dir bare)

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)

git-remote-add (name url)

Add remote with NAME and URL.

(git-remote-add "foo" "foo@git.com")

git-remote-remove (name)

Remove remote with NAME.

(git-remote-remove "foo")

git-reset ()

Reset to COMMIT with MODE.

(git-reset)
(git-reset "HEAD~1" 'hard)

git-rm (path)

Remove PATH.

To remove directory, use RECURSIVE argument.

(git-rm "foo")
(git-rm "bar" :recursive)

git-stash (&optional message)

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")

git-stash-pop (&optional name)

Apply and remove stash with NAME (or first stash).

(git-stash-pop)
(git-stash-pop "stash@{3}")

git-stash-apply (&optional name)

Apply and keep stash with NAME (or first stash).

(git-stash-apply)
(git-stash-apply "stash@{3}")

git-tag (tag)

Create TAG.

(git-tag "tag")

git-clone (url &optional dir)

Clone URL to DIR (if present).

(git-clone "foo@git.com")
(git-clone "foo@git.com" "bar")

git-fetch (&optional repo ref)

Fetch REPO.

(git-fetch)
(git-fetch "origin" "master")

git-pull (&optional repo ref)

Pull REF from REPO.

(git-pull)
(git-pull "origin" "master")

git-push (&optional repo ref)

Push REF to REPO.

(git-push)
(git-push "origin" "master")

git-run (command &rest args)

Run git COMMAND with ARGS.

(git-run "log")
(git-run "log" "--name-only")
;; ...

Notes

For each command, you can add arguments using git-args.

(let ((git-args "--hard"))
  (git-reset "HEAD"))

Contribution

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

About

An Elisp API for programmatically using Git

Resources

Stars

Watchers

Forks

Packages

No packages published