原文 Hacking on AS http://communityjbossorg/wiki/HackingonAS
注jbossas 使用 github 来管理源代码所以要求阅读者有基本的git知识可以阅读一下<<pro git>>书籍
创建github帐号
http://githubcom
Fork 你的jbossas 副本
http://githubcom/jbossas/jbossas
用Git克隆你的副本到本机工作区
$ git clone git@githubcom:[your user]/jbossasgit
Initialized empty Git repository in /devel/jbossas/git/
remote: Counting objects: done
remote: Compressing objects: % (/) done
remote: Total (delta ) reused (delta )
Receiving objects: % (/) MiB | KiB/s done
Resolving deltas: % (/) done
$ cd jbossas
将git远程引用添加为upstream 为了以后使用pull来更新
git remote add upstream git://githubcom/jbossas/jbossasgit
使用maven (通过命令 buildsh) (确实你在使用 maven )
$ /buildsh install
[INFO]
[INFO] Reactor Summary:
[INFO]
[INFO] JBoss Application Server: BOM SUCCESS [s]
[INFO] JBoss Application Server: Parent Aggregator SUCCESS [s]
[INFO] JBoss Application Server: Domain Core SUCCESS [s]
[INFO] JBoss Application Server: Server Manager SUCCESS [s]
[INFO] JBoss Application Server: Server SUCCESS [s]
[INFO] JBoss Application Server: Domain Controller SUCCESS [s]
[INFO] JBoss Application Server: Process Manager SUCCESS [s]
[INFO] JBoss Application Server: Remoting SUCCESS [s]
[INFO] JBoss Application Server: Build SUCCESS [s]
[INFO]
[INFO] BUILD SUCCESS
[INFO]
从 upstream 拉取(pull)更新
写道
$ git pull rebase upstream master
From git://githubcom/jbossas/jbossas
* branch master > FETCH_HEAD
Updating fadf
Fastforward
{parent => bom}/pomxml | ++++
build/pomxml | +
domain/pomxml | ++
/src/main/resources/examples/hostexamplexml | +
/resources/examples/jbossdomainexamplexml | +++
/main/resources/schema/jbossdomaincommonxsd | +
/main/resources/schema/jbossdomainhostxsd | +
domain/src/main/resources/schema/jbossdomainxsd | ++
pomxml | ++++++++++++++++++
processmanager/pomxml | +
files changed insertions(+) deletions()
rename {parent => bom}/pomxml (%)
(如果你有本地提交rebase 会自动将你本地的提交移动到分支的顶端便于生成清晰的提交记录方便他人合并如果没有本地提交可以不加 rebase) 请注意 rebase 非常重要如果你确实有本地提交如果git pull不能快速移动指针它会合并提交如果不是用rebase它会给予你本地的修改进行合并而rebase则是将你的修改与upstream进行合并也就是说一个合并提交会产生修改historyrebase会让历史更加的清晰和简单而一旦你做了本地提交今后将很难重建在此此提交之前的历史 在中还会讨论
有一个办法让你不会忘记 rebase 选项就是给"pull rebase;创建一个别名
$ git config global aliasup "pull rebase"
然后使用新的别名而不是 pull
$ git up upstream master
另一个更加推崇的办法是避免同时使用 pull 和 rebase而是用 fetch+rebase不过这已经超过了该文的内容可以参考git的文档
$ git config global aliasup "pull rebase"
推送(push) 你拉取(pull)的更新到你个人的github repo
Java代码
$gitpush
Countingobjects:done
Deltacompressionusinguptothreads
Compressingobjects:%(/)done
Writingobjects:%(/)KiBdone
Total(delta)reused(delta)
Togit@githubcom:[youruser]/jbossasgit
fadfmaster>master
你可能加上 f 参数用来强行提交你的修改参考注释
讨论你计划的修改 (如果你想要得到反馈)
为你的修改(增强/修复bug)发布一个JIRA
http://jirajbossorg
创建一个简单的主题分支(branch)来隔离这项工作 (仅作为一个推荐方法)
Java代码
gitcheckoutbmy_cool_feature
Note: See tips section for how to use a nice git prompt for tracking what branch you are in!
不断的修改并且提交你的修改 (不要忘了push)
Java代码
gitcommitm;JBASXXXXFrunubucatetheFromungulator;
gitcommitm;JBASYYYYTripplePerformanceofFromungulation;
gitpushmy_cool_feature
注意 git push 默认引用你正在push的branch默认为 master而不是你正在工作的branch
给予master分支的最新更新重建/衍合(rebase)你的分支(将你的提交更新到master的顶端)
git fetch upstream
git rebase i upstream/master
# if you have conflicts fix them and rerun rebase
# The f forces the push alters history see note below
git push f origin my_cool_feature
选 项i会启动交互式的更新它允许你组合提交调整commit信息等这是一个好的方法使得commit日志非常清晰对于外部的更新注意这会修改提交 历史产生干净的patch对于其他已经fork你的分支的人并不友好所以你需要确认要么你工作在一个没有共享的分支上或者你共享了则需要告诉他 们你将修订分支的历史(因此一旦是推送完毕之后他们需要给予你分支的顶部做rebase)
将你的修改merge到upstream
在你请求将你的更新合并到upstream之前请重复步骤确认你的repo和upstream是同步的
发送一个pull request email tojbossaspullrequests@listsjbossorg(要加入这个list参考here)附上你的repo的链接描述你的修改谁检查你的改动(如果有的话)
在检查之后管理员会合并你的patchupdate/resolve你请求中问题并回复什么时候完成
不会忘了切换会master分支并且拉取更新
git checkout master
git pull upstream master