Question

I made my first pull-request not long ago, and I found a bug in the code.(meh)

I don't want to make a new branch and commit/push/pull request the new branch since this must have been in the first pull-request.

Do I drop the pull-request and submit a new request?
Are there other ways?

EDIT

I did 'git commit --amend' but I can't push it.

I see my latest commit is now #B, while the original commit was #A and github webpage shows my pull requests is pointing at #A

I did 'git push my_github_fork MyWork_branch but it says Everyhing-up-to-date.

I tried giving -f option to it but no avail.

Was it helpful?

Solution

If the repo has not been yet pulled, you can simply fix the bug with a further commit, which will be pulled.

OTHER TIPS

If you would like to keep your pull-request clean, I would recommend rebasing the commits in your branch so that the bug isn't even visible, and force-pushing your branch to GitHub.

If you're fixing your latest commit, this is as simple as amending it:

git commit --amend

GitHub will automatically update the commits in your pull-request with whatever is in that branch, so when this is viewed by the developers in the other repository, they will simply see the commits that you want them to see.

I always try to make sure that commits in git tell some kind of story -- it should be clear what you're doing from the commit history. When a pull-request gets littered with mistakes and later commits that fix them, it makes it really hard to understand that story.

I have been on the receiving-end of many a pull-request that was messy and unclear. I definitely recommend rebasing the branch to keep everything crystal clear.

GitHub pull requests will automatically update any time you update the branch they are pulling from. So, go ahead and push an additional commit or amend your previous commit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top