I am about to merge my developer branch to my master on gitlab. I commited by mistake a lot of files that I didnt wanna have on my master (they are about 150 files). I have created a merge request, but havent merged the branches yet. Is there any way to not merge all these 150 files and merge only the ones I want? Is there maybe any way to add a .gitignore file while merging? I am new to git and cant really find my way around this problem.
Thanks in advance for your help!
I would recomend making a new branch to try edits first so you don't mistakenly remove something permanently from the branch you have been working on. You can use,
git checkout -b <new-branch>
Any uncommited changes will come with it so you may want to make sure you are up to date before doing so. Then try the following before merging into master.
Check out this answer, you can remove a single file,
To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use:
git rm --cached filename
Or remove all files in your updated gitignore,
To untrack every file that is now in your .gitignore:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"