我正在寻求一些帮助,请使用 Emacs / Magit 将本地存储库更改推送到远程网站和 Github。
我找到了一个非 Emacs / 非 Magit 相关的线程 ( https://stackoverflow.com/a/3195446/2112489 ),评论指出这是推送到远程和 Github 的最终答案,它有一个几百个竖起大拇指。我假设(可能是错误的)这是我计算机目录中本地 .gitconfig
文件的一个很好的起点。$HOME
[remote "GitHub"]
url = git@github.com:elliottcable/Paws.o.git
fetch = +refs/heads/*:refs/remotes/GitHub/*
[branch "Master"]
remote = GitHub
merge = refs/heads/Master
[remote "Codaset"]
url = git@codaset.com:elliottcable/paws-o.git
fetch = +refs/heads/*:refs/remotes/Codaset/*
[remote "Paws"]
url = git@github.com:Paws/Paws.o.git
fetch = +refs/heads/*:refs/remotes/Paws/*
Emacs / Magit 中的基本 Push 命令一次只推送一个:
C-u P P [and then use arrow keys to select from the choices in the minibuffer] RET
查看可用命令的 Magit 备忘单:http: //daemianmack.com/magit-cheatsheet.html
试想——/usr/local/git/bin/git remote -v
用来获取已经配置好的遥控器列表,然后用结果推送到每一个。. . 可行,但复杂。
$ MP:my_project.git HOME$ /usr/local/git/bin/git remote -v
origin git@github.com:lawlist/my_project.git (fetch)
origin git@github.com:lawlist/my_project.git (push)
remote_website lawlist@my-website.com:my_project.git (fetch)
remote_website lawlist@my-website.com:my_project.git (push)
命令行配方——分别推送到遥控器和 Github:
;; Setup the remote repository and the hook; and the remote destination folder.
ssh lawlist@my-website.com
mkdir /home/lawlist/my_project.git
cd my_project.git
git init --bare
;; git update-server-info # If planning to serve via HTTP
cat > /home/lawlist/my_project.git/hooks/post-receive ;; RET
#!/bin/sh ;; RET
GIT_WORK_TREE=/home/lawlist/my_project git checkout -f ;; RET
;; C-d
chmod 755 /home/lawlist/my_project.git/hooks/post-receive
mkdir /home/lawlist/my_project
exit
;; On local machine.
mkdir /Users/HOME/.0.data/.0.emacs/elpa/my_project.git
touch /Users/HOME/.0.data/.0.emacs/elpa/my_project.git/README.md
cd /Users/HOME/.0.data/.0.emacs/elpa/my_project.git
/usr/local/git/bin/git init
/usr/local/git/bin/git add .
/usr/local/git/bin/git commit -m "First commit."
curl -u lawlist:12345678 https://api.github.com/user/repos -d '{"name":"my_project.git"}'
/usr/local/git/bin/git remote add origin git@github.com:lawlist/my_project.git
/usr/local/git/bin/git remote add remote_website lawlist@my-website.com:my_project.git
/usr/local/git/bin/git push origin master
/usr/local/git/bin/git push remote_website master
;; For modification of local files
/usr/local/git/bin/git add .
/usr/local/git/bin/git commit -m "This is a modification . . . ."
/usr/local/git/bin/git push origin master
/usr/local/git/bin/git push remote_website master