I've start contributing on a closed-source project. The lead developer asked me to use the method below to contribute on this project.
I write this document to help all the people who are new on this method (See below) of contributing on git projects.
- Fork the project from the upstream repository (I name the base repository, upstream).
- Clone the forked repository on your local machine.
- Add upstream which point to the upstream on the fork repository.
- Fetch upstream.
- Checkout the master branch & Create a new branch for each feature (Follow the git flow).
- Add files to this branch.
- Commit & push the code (Also the branch) into your source control.
- Open a pull request on the github/git provider.
- Add other features (Start from step 5).
- Fetch upstream.
- Each time a pull request resolved/closed/accepted, switch to the master branch and rebase it with upstream/master.
- Push commit information retrieved via rebase (commit history & ...).
Start from step 2.
# 2) Clone the code
$ git clone your-git-repository-url
# 3) Add upstream
$ git remote add upstream upstream-git-url
# 4) Fetch upstream
$ git fetch upstream
# 5) Create a new branch
$ git checkout master && git checkout -b your-new-branch-name
# 6) Add files
$ git add . && git add --all
# 7) Commit & push the code
$ git commit -m "your message goes here" && git push --set-upstream origin your-new-branch-name
# 8) Do it on github/git web interface. I don't know how to do this in CLI
# 10 & 11) After pull request resolved
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
# 12) Push commit information
$ git push