Skip to content

Instantly share code, notes, and snippets.

@lgatto
Last active January 11, 2023 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgatto/58ef4c6fab8f637218216bc46033bf98 to your computer and use it in GitHub Desktop.
Save lgatto/58ef4c6fab8f637218216bc46033bf98 to your computer and use it in GitHub Desktop.
Pulls and pushes a few github repos in bash and elisp
;; Pulls and pushes a few github repos from emacs
;; Laurent Gatto (https://github.com/lgatto)
;; Thanks to Stephen J. Eglen for his help in redirecting to a
;; dedicated buffer (https://github.com/sje30)
(setq git-dirs '(
"~/wd"
"~/bin"
"~/Documents/org"
"~/Documents/roam"
))
(defun push-or-pull (direction)
"Push/pull to/from many repositories."
(interactive)
(let ((buf (get-buffer-create "*push-pull*"))
(shell-command-dont-erase-buffer t))
(save-excursion
(set-buffer buf)
(erase-buffer))
(dolist (item git-dirs)
(shell-command (format "echo %sing %s" (capitalize direction) item) buf)
(shell-command (format "cd %s; git %s" item direction) buf)
)
(pop-to-buffer buf)
(goto-char (point-max))
)
)
(defun pull-many ()
"Pull from many repositories."
(interactive)
(push-or-pull "pull"))
(defun push-many ()
"Push to many repositories."
(interactive)
(push-or-pull "push"))
#!/bin/bash
dirs=(
~/wd
~/bin
~/Documents/attachments
~/Documents/org
~/Documents/roam)
for dir in ${dirs[@]}
do
echo "-> Pulling from" $dir
cd $dir
git pull
done
#!/bin/bash
dirs=(
~/wd
~/bin
~/Documents/attachments
~/Documents/org
~/Documents/roam)
for dir in ${dirs[@]}
do
echo "-> Pushing from" $dir
cd $dir
git push
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment