0

I've made changes in a project in Visual Studio and committed them. It's connected to my GitHub repository. Now, I haven't pushed it, because it won't work. After further investigation, I found that I accidentally added a huge file in my commit, which Visual Studio now tries to push up to my GitHub Repo. But since it's such a huge file, it won't be uploaded and I dont know how to delete it from that commit.

So I would like to know: How to access and modify/delete files from a non-pushed commit in Visual Studio?

And if that is not an option, how should I proceed otherwise? I already made more changes in the project, so I maybe have to do a rebase or something?

I found other threads, but those we're about changing the message, not the files themself, or they were about an already pushed commit.

Any help is appreciated!

Vandrey
  • 531
  • 1
  • 8
  • 23
  • 1
    You can use [`amend` within VS](https://saraford.net/2017/03/15/how-to-amend-changes-to-your-code-in-your-most-recent-commit-074/). Change what you want to change and in the `Team Explorer - Changes` window click `Actions` and `Amend Previous Commit`. This will change the last commit and rewrites it with your changes (amend). – kapsiR Nov 03 '20 at 09:55
  • Oh man you really helped my out there! Thank you so much!!! Would you turn your comment into an answer, if its appropriate? – Vandrey Nov 03 '20 at 10:24
  • 1
    Sure, I've added this as answer – kapsiR Nov 03 '20 at 11:22

2 Answers2

1

You can use amend within VS.

Change what you want to change and in the Team Explorer - Changes window click Actions and Amend Previous Commit.

This will change the last commit and rewrites it with your changes (amend).

On the CLI, this would look like the following: git commit --amend (with options to change the message too)
The documentation is pretty good on that topic:

kapsiR
  • 2,720
  • 28
  • 36
0
  • Navigate to Git Repository
  • Right click on commit and select 'View Commit Details'
  • In the right panel , select Amend Message
  • Change message and then Push
Phalak
  • 9
  • 1