- adding some changes by the owner.
- some changes by a contributor.
- yet another change by the owner.
- yet another change by a contributor.
- final change by the owner.
- final change by a contributor.
The first time you start contributing:
-
Fork the repo on github.
-
git clone https://github.com/<your-username>/repo.git
-
cd /path/to/repo
-
Add a remote called e.g.
upstream
points to the original repo:
git remote add upstream https://github.com/<repo-owner>/repo.git
-
Assuming the main branch of original repo is
master
, pull repo before editing:
git pull upstream master
-
Create a new branch called e.g.
topic-branch
to develop and test features without putting your main project at risk.
git checkout -b topic-branch master
-
Do some changes.
-
Commit snapshots of those changes into your repo (use
-a
flag to add files on the stagegit add .
):
git commit -a -m "your commit message here"
-
Push
topic-branch
commits to your remote repo stored on GitHub, usingorigin
remote.
git push origin topic-branch
-
Send a pull request.
Now and later on:
-
Make
master
the active branch.
git checkout master
-
Pull original repo before editing:
git pull upstream master
-
Make
topic-branch
the active branch.
git checkout topic-branch
-
Use
rebase
ormerge
to make sure that your commits go on top of themaster
branch:
git rebase master
orgit merge --no-ff master
-
Do some changes.
-
Commit snapshots of those changes into your repo (use
-a
flag to add files on the stagegit add .
):
git commit -a -m "your commit message here"
-
Push commits to your remote repo stored on GitHub. If you want to keep all branches up-to-date, do NOT add
topic-branch
at the end of the code below:
git push origin
I hope this approach will be helpful for you ;)