If you merge master
onto your feature
branch without rebasing it, and push the changes, then your branch may get cluttered. And also, your pull-request might show files that were not modified by you: the files that were edited again in master
after your merge. That can be fixed by squashing all the previous commits with the help of a temporary branch:
- git checkout -b temp master
- git merge --squash feature
- git commit
- git checkout feature
- git reset --hard temp
- git branch -d temp
- git push --force
This way you get only one commit and your pull-request will show only files that were modified by you. I have found this solution in Stack Overflow, and it helped me with one of my tasks.