Hey all! New year, new post *ba dum tss*
So this week I was having a bit of a slow morning, and when creating a new pull request I did not realise that I included an already existing file by mistake. Thankfully, I realised that I was about to merge unwanted changes before the reviewer got a chance to look at my PR, but I was now facing another issue. Is there a way to remove just one file without deleting the whole pull request?
After a quick search I found a solution that suits my problem.😎👌
Check out on the branch that has your PR, replace the file with an unmodified version (of the same file) from a different branch (in my case master branch), commit the changes and finally push to the same PR. Git commands, to be typed in Visual Studio’s Package Manager Console, below.
| git checkout branch-that-has-pr | |
| git checkout origin/master -- C:\somefolder\someotherfolder\thefile.cs | |
| git commit -m "Removed a file from pull request" | |
| git push origin branch-that-has-pr |
Short and sweet, and works like a charm. Until next post,
Bjorn
Thank you ! It works like a charm 🙂
Step 2 will raise an error because of “— ” So you have to replace it with “–” (two dashes)
LikeLike
Thanks for letting me know. This is a weird one. If you had to click on that snippet (and get redirected to https://gist.github.com/) it would show with a double dash, but somehow when embedded in my blog it shows just one longer dash. Need to investigate.
LikeLike
Pingback: pull specific file or directory from a remote branch | It's not a bug, it's a feature