3

I have created and edited a fork, and submitted a pull request. However, there are many commits on it and I would like to remove some of the irrelevant ones. How do I do this?

I have looked at many other answers (such as this one), but they all address slightly different problems, and as I am new to GitHub I don't know how to put them all together.

Thanks.

Frick Steves
  • 365
  • 4
  • 11
  • 2
    Search for squash, (interactive) rebase and force push. Just remove/edit the commits in your branch and do a force push. – Julian Aug 25 '17 at 22:59

2 Answers2

2

Interactive rebase works generally, and is almost always a better solution (details here). However, I had problems with it and had to go about it a different way.

1) Re-cloning your fork to another location, something like:

git clone /your-username/your-repo

2) Restart your fork from upstream (details here):

git remote add upstream /url/to/original/repo
git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force` 

3) Replace relevant files within repo and commit changes. After making your necessary changes again:

git commit -m "<commit message>"
git push origin <relevant-branch>

Hope this helps someone some time.

Frick Steves
  • 365
  • 4
  • 11
-1

For that you can goto the previous commit using

git checkout {commit_id} for commit id you can use git log

After that you can do new commit with your desired changes.

For further read git-checkout Git log