git clone https://github.com/foo/rocketmq.git
git remote add apache https://github.com/apache/rocketmq.git
git remote -v
apache https://github.com/apache/rocketmq.git (fetch)
apache https://github.com/apache/rocketmq.git (push)
origin https://github.com/foo/rocketmq.git (fetch)
origin https://github.com/foo/rocketmq.git (push)
Note: https://github.com/apache/rocketmq.git is a read-only repo, mirrored from git://git.apache.org/rocketmq.git. For submitting PR, fork this read-only repo on Github is OK.
you'd better use a new branch for each PR, for it is convenient to manage your code and commits
git checkout -b new_pr
//do something and commit
git fetch apache
git rebase apache/develop
Note: if using merge, it will dirty the commits
the difference between rebase and merge can refer to:
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
you can code and commit as usual. But when you think it is time to submit a PR, it is better to squash your commits into single one, for that others can easily identify your PR from the history commits. you can squash as follows:
gt reset <the latest commit that dose not belong to you PR>
git add --all
git commit -m “attach the issue or jira”
git push (if the commits have been already pushed to your remote repo, git push will fail , use git push -f instead)
For example:
git log
git resset b4108d2d9d3b1522e45ac5e7ea37106f2135bfa0
git commit -m ‘Add batch feature’
git log
git push
For now, we have finished the preparations of a PR. It is time to create it. For apache projects, we could attach the jira issue using specific title like “[XXX] add something”, such as “[ROCKETMQ-80] Add batch feature”, the “XXX” represents the the name of the jira issue. you could refer to: