I cloned a git repository from GitHub, made some changes and some commits; I made quite a lot and all are quite dirty, so they\'re not suitable for a pull request. Now I created
Another way, if you want to create a new commit instead of performing a merge:
git checkout cleanchanges
git reset --hard master
git reset cleanchanges
git status
git add .
git commit
The first (hard) reset will set your working tree to the same as the last commit in master
.
The second reset will put your HEAD back where it was, pointing to the tip of the cleanchanges
branch, but without changing any files. So now you can add and commit them.
Afterwards, if you want to remove the dirty commits you made from master
(and assuming you have not already pushed them), you could:
git checkout master
git reset --hard origin/master
This will discard all your new commits, returning your local master
branch to the same commit as the one in the repository.