Github: Pull-request & Rebase
Today I will take note for one tips of pull-request.
For example, imagine this scenario.
1. Fork from upstream repository.
- upstream: https://github.com/foo/bar.git
- forked: https://github.com/junaruga/bar.git
2. Git clone from forked own repository (= origin)
$ git clone https://github.com/junaruga/bar.git
$ cd bar
3. Create a feature branch for one feature.
$ git checkout -b feature/something
4. Modify & push to my own repository
$ vi foo.txt $ git add foo.txt $ git commit -m 'Something' $ git push origin feature/something
5. Do pull-request from own repo: feature/something to upstream: master.
At this moment, only 1 commit.
6. Get the review from upstream people.
7. Push modification after the review to own repository: feature/something
At this moment For example 3 commits.
we should do "rebase" & squash after every modification, and unify 1 commit from these commits.
That means
$ git rebase -i commit_hash_before_your_modification
pick
s
s
...
$ git push origin feature/somthing -f
origin is own repository.
And upstream's pull-request page is no problem after above command.
The previous modification's comment and file & lines are saved on the page.
And total commit & file difference info was updated.
So, again.
We should do "rebase" & squash after every modification, and unify 1 commit from these commits, for pull-request.