* [[http://jonathan2251.github.com/lbd/index.html|Write An LLVM Backend Tutorial For Cpu0]]
* [[https://github.com/azru0512/lbd]]
* [[http://mark-story.com/posts/view/creating-multi-language-documentation-with-sphinx|Creating multi-language documentation with sphinx]]
在 github 上 fork 一個 repo。基本上是開新的 branch,並以此為基礎送
pull request 給 upstream。
* [[http://stackoverflow.com/questions/4658606/import-existing-source-code-to-github|Import existing source code to github]]
- 簽出代碼,master 與上游同步。
$ git clone git@github.com:azru0512/lbd.git
$ cd lbd
$ git remote add upstream https://github.com/Jonathan2251/lbd.git
# 將分支 master 和 upstream 的分支 master 同步。
$ git branch --set-upstream upstream/master
# git fetch upstream; git merge upstream/master 等同底下指令。
$ git pull upstream master
# 建立並切換分支
$ git checkout -b format
# 將分支 push 回 github 上的 (remote) origin
$ git push origin format
# 切換回 master
$ git checkout master
* [[https://help.github.com/articles/fork-a-repo|Fork A Repo]]
* [[https://help.github.com/articles/using-pull-requests|Using Pull Requests]]
* [[http://www.kernel.org/pub/software/scm/git/docs/v1.7.3/user-manual.html#resolving-a-merge|Resolving a merge]]
* [[http://gun.io/blog/how-to-github-fork-branch-and-pull-request/|How to GitHub: Fork, Branch, Track, Squash and Pull Request]]
* [[https://github.com/Kunena/Kunena-2.0/wiki/Create-a-new-branch-with-git-and-manage-branches|Create a new branch with git and manage branches]]
* [[http://blog.wu-boy.com/2011/08/git-cherry-pick-%E8%99%95%E7%90%86%E5%B0%88%E6%A1%88-pull-request/|git cherry-pick 處理>專案 pull request]]
- 挑幾個 commit 合併回自己的版本。
# 更新 master (由他人的 repo fork 而出),自己的是 private。
$ git checkout private
$ git log --graph --oneline --all
| | * 2b87a72 Correct typing
| | * 2224bae Correct typing
| |/
|/|
* | 1fd948f fix 80 characters of column width in funccall.rst
# 挑選 master 某個 commit 合併。
$ git cherry-pick 2224bae
# 處理需要合併的檔案。
$ git status
# Unmerged paths:
# (use "git add ..." to mark resolution)
#
# both modified: source/funccall.rst
#
$ git add source/funccall.rst
$ git commit
$ git push
* [[http://sg552.iteye.com/blog/1300713|git cherry-pick. 如何把已经提交的commit, 从一个分支放到另一个分支]]
* [[https://ariejan.net/2010/06/10/cherry-picking-specific-commits-from-another-branch|Cherry-Picking specific commits from another branch]]
- 將分支 master 與另一個遠端分支 master 同步。寫入設定。
$ git clone git@github.com:azru0512/lbd.git -b master
$ cd lbd
$ git config --global branch.master.remote https://github.com/Jonathan2251/lbd.git
- 將另一個遠端分支 master 的內容拉下來,同步到自己的遠端 (origin) 分支 master。
# pull Jonathan2251/lbd.git
$ git pull
$ git push origin
- private 分支以 master 做 rebase,並處理 conflict。
$ git checkout private
# 將 master 內容合併回 private 分支,將 "<<< ===" 或 "=== >>>" 其中之一消除掉。
$ git rebase master
$ git status
# Not currently on any branch.
# 顯示尚未從 master merge 回 private 的第一個 commit。
$ git log -1 --pretty=oneline
# 修改 conflict
$ git mergetool
# 手動修改 conflict 需要 add 處理完 conflict 的檔案。
$ git add source/install.rst
$ git commit -am "Rebase master"
# 查看 master 和 branch 合併情況。
$ git log --graph --oneline --all
* [[http://gogojimmy.net/2012/01/21/how-to-use-git-2-basic-usage-and-worflow/|Git 教學(2):Git Branch 的操作與基本工作流程]]
* [[http://stackoverflow.com/questions/2498458/why-did-git-set-us-on-no-branch|Why did git set us on (no branch)?]]
* [[http://www.jarrodspillers.com/2009/08/19/git-merge-vs-git-rebase-avoiding-rebase-hell/|git merge vs git rebase: Avoiding Rebase Hell]]
$ git checkout -b private
$ git checkout cmdline
# 刪除 private 分支
$ git branch -D private
$ git push origin --delete cmdline
* [[http://nelsonchunglife.blogspot.tw/2010/12/gitbranch.html|刪除由git建出的branch]]
* [[http://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-both-locally-and-in-github|How do I delete a Git branch both locally and in Github?]]
$ vi source/funccall.rst
# 檢查是否有多餘的空白
$ git diff --check
# 合併最近兩個 commit。
$ git rebase -i HEAD~2
* [[http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html|squashing commits with rebase]]
$ mkdir en
$ git mv Fig/ en/
# 修改最近一個 commit message。
$ git commit --amend -m "New commit message"
* [[http://stackoverflow.com/questions/179123/how-do-i-edit-an-incorrect-commit-message-in-git]]
* [[http://www.gitguys.com/topics/git-and-remote-repositories/|Git And Remote Repositories]]
* [[http://www.gitguys.com/topics/the-configuration-file-branch-section/|The Configuration File - "Branch" Section]]
$ git reset HEAD^ # remove commit locally
$ git push origin +HEAD # force-push the new HEAD commit
* [[http://christoph.ruegg.name/blog/2010/5/5/git-howto-revert-a-commit-already-pushed-to-a-remote-reposit.html|Git Howto: Revert a Commit Already Pushed to a Remote Repository]]
* [[http://stackoverflow.com/questions/8225125/remove-last-commit-from-remote-git-repository|Remove last commit from remote git repository [closed]]]
- 建立分支 gh-pages。注意,gh-pages 裡必須清空,不可包含原本分支的檔案。
$ cd repo
$ git checkout --orphan gh-pages
$ git rm -rf .
$ echo "First commit" > index.html
# 如果有檔案或是目錄以底線開頭,加上以下檔案才能正確處理。
$ touch .nojekyll
$ git add .
$ git commit -m "Just to create the branch."
$ git push origin gh-pages
* [[https://help.github.com/articles/files-that-start-with-an-underscore-are-missing|Files that start with an underscore are missing]]
- 修改欲建立網頁的分支,新增 Makefile 目標。
$ git checkout master
$ vi Makefile
gh-pages:
git checkout gh-pages
rm -rf build _sources _static
git checkout master $(GH_PAGES_SOURCES)
git reset HEAD
make html
mv -fv build/html/* ./
rm -rf $(GH_PAGES_SOURCES) build
git add -A
git ci -m "Generated gh-pages for `git log master -1 --pretty=short --abbrev-commit`" && git push origin gh-pages ; git checkout master
$ git add Makefile
$ git commit -m "Update Makefile"
$ git push
- 於欲建立網頁的分支建立網頁。
$ make gh-pages
* [[http://blog.nikhilism.com/2012/08/automatic-github-pages-generation-from.html|Automatic Github Pages generation from Sphinx documentation]]
* [[http://www.tumblr.com/tagged/github-pages|Hosting Sphinx documentation on GitHub]]
* [[http://datadesk.latimes.com/posts/2012/01/sphinx-on-github/|Sphinx documentation on GitHub]]
- 目的是將範例程式獨立成 submodule。
$ git submodule add git@github.com:azru0512/lbd-example.git example
$ git commit .gitmodules lbd-example -m "Add lbd-example submodule"
$ git submodule init
$ git submodule update
* [[http://blog.wu-boy.com/2011/09/introduction-to-git-submodule/|Git Submodule 介紹與使用]]
* [[http://josephjiang.com/entry.php?id=342|Git Submodule 的認識與正確使用!]]
* [[http://stackoverflow.com/questions/11817338/how-to-add-submodule-into-gh-pages-branch-build-static-pages-correctly|How to add submodule into gh-pages branch & build static pages correctly?]]
* [[http://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository|How do I move an existing git submodule within a git repository?]]
====== 外部連結 ======
* [[http://sphinx-doc.org/]]
* [[http://sphinx-doc-zh.readthedocs.org/en/latest/]]
* [[http://nipy.sourceforge.net/devel/guidelines/sphinx_helpers.html|Sphinx Cheat Sheet]]
* [[https://bitbucket.org/arjones6/sphinx-numfig/wiki/Home|sphinx-numfig]]
* [[http://sourceforge.net/p/numfig/wiki/Home/|Numfig: a Sphinx package for numbering figures]]