我正在尋找一些援助,請使用Emacs/Magit將本地存儲庫更改推送到遠程網站和Github一舉。Emacs - 如何將Git存儲庫推送到多個遙控器
我發現了一個非Emacs /非Magit相關線程(https://stackoverflow.com/a/3195446/2112489),其中有評論指出它是推送到遠程和Github的權威答案,並且它有幾百個大拇指。我假設(也許不正確)這是我的計算機上的$HOME
目錄中的本地.gitconfig
文件的一個很好的起點。
[remote "GitHub"]
url = [email protected]:elliottcable/Paws.o.git
fetch = +refs/heads/*:refs/remotes/GitHub/*
[branch "Master"]
remote = GitHub
merge = refs/heads/Master
[remote "Codaset"]
url = [email protected]:elliottcable/paws-o.git
fetch = +refs/heads/*:refs/remotes/Codaset/*
[remote "Paws"]
url = [email protected]:Paws/Paws.o.git
fetch = +refs/heads/*:refs/remotes/Paws/*
在Emacs/Magit基本按命令只推一次一個:
C-u P P [and then use arrow keys to select from the choices in the minibuffer] RET
查看可用命令的Magit的cheatsheet: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 [email protected]:lawlist/my_project.git (fetch)
origin [email protected]:lawlist/my_project.git (push)
remote_website [email protected]:my_project.git (fetch)
remote_website [email protected]:my_project.git (push)
命令行RECIPE - 分別推到遠程和Github上:
;; Setup the remote repository and the hook; and the remote destination folder.
ssh [email protected]
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 [email protected]:lawlist/my_project.git
/usr/local/git/bin/git remote add remote_website [email protected]: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
+1感謝分享! – itsjeyd