As I understand it, you did a commit including a bunch of unwanted files on your developer
branch. I will assume you did this in your last commit. You can simply return to the previous commit with the git --soft
command:
# we are on branch `developer`
git reset --soft HEAD~1
Now you are back to the previous commit, but still with all the changes in the staging area (thanks to the --soft
flag). But, your 150 unwanted files are also stilll in the staging area (use git status
to monitor that). So, you did not loose any changes that actually matter, but we need to remove the 150 unwanted files from the staging area.
Now you have several options. You could unstage each one of the 150 files like this:
git reset -- path/to/unwanted/file001
This is not a pleasant job though, especially if you have to repeat this 150 times. You could simply unstage all your files:
git reset
and stage the files you want to commit to the developer
branch:
git add path/to/wanted/file01
A third option would be to unstage all the files with git reset
, edit your .gitignore
file, and finally add the changes to the staging area with:
git add --all
Your .gitignore
should then prevent the 150 unwanted files from being added to the staging area.
So, summarizing:
git reset --soft HEAD~1 # or HEAD~N if you created the unwanted files N commits ago
git reset
/* edit your .gitignore file */
git add --all
/* commit the results */