以项目
flask-security
为例
Fork
开源项目到自己的账号
-
打开https://github.com/并登录自己的账号
-
打要参与的开源开项目主页:
比如 https://github.com/mattupstate/flask-security/ -
Fork
该项目到自己的账户下(点击右上角的Fork
按钮) -
打开刚刚
Fork
的仓库主页(在自己的账号下面) -
clone
该仓库到本地,以我自己的账号Steinkuo为例:git clone https://github.com/Steinkuo/flask-security.git
(如果没有设置
ssh rsa public key
也可以使用https
协议) -
切换到相应的分支:
git checkout develop
(flask-security项目最新的变更在
develop
,一般是master
) -
翻译文件并上传:
python3 -m venv env
pip install -r requirements.txt
pybabel init -i flask_security/translations/flask_security.pot -d flask_security/translations -l zh_Hans_CN
vim flask_security/translations/zh_Hans_CN/messages.po
# no compile
# pybabel compile -d flask_security/translations/
git add .
git commit -m "i18n: added Chinese-Simple translation"
# 修改本地代码,提交,最后推送到远程仓库:
git push origin develop
# (flask-security项目最新的变更在develop,一般是master)
提交自己修改的内容到源仓库
-
假设你的改动已经推送到自己账户下的远程仓库
-
登录
github
打开自己Fork
的仓库,点击New pull request
按钮 -
然后会跳转到,原作者的repo下,出现pull request的界面,你就选择一下想要提交的branch就行了,如果有文件可以提交,下面会有commit的按钮,你填一下description就ok了,然后等作者merge。
保持Fork
的库和源库代码同步
-
查看前面
clone
下来代码的远程仓库的路径:git remote -v
-
配置源仓库(开源项目的)的路径:
(env) ➜ flask-security git:(develop) git remote add upfork [email protected]:mattupstate/flask-security.git (env) ➜ flask-security git:(develop) git remote -v origin https://github.com/Steinkuo/flask-security.git (fetch) origin https://github.com/Steinkuo/flask-security.git (push) upfork [email protected]:mattupstate/flask-security.git (fetch) upfork [email protected]:mattupstate/flask-security.git (push)
-
同步源仓库的提交的变更:
git fetch upfork
-
合并源仓库某个分支的变更到当前本地分支:
git merge upfork/develop
(flask-security
项目最新的变更在develop
,一般是master
) -
此时,你的本地库已经和源仓库已经完全同步了。但是注意,此时只是你电脑上的本地库和远程的
github
源仓库同步了,你自己账户的github
仓库还没有同步,此时需要使用git push origin master
命令把你本地的仓库提交到自己账户的github
中。