Git – How to edit or remove a “pushed” commit using Visual Studio

This is how you edit or remove a “pushed” commit using Visual Studio. (Just for reference, I am using Visual Studio 2022)

Removing your previous commit from your local repo using Reset

On the menu bar in Visual Studio, click on Git -> View Bran…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by thebernardlim

This is how you edit or remove a "pushed" commit using Visual Studio. (Just for reference, I am using Visual Studio 2022)

  1. Removing your previous commit from your local repo using Reset

    • On the menu bar in Visual Studio, click on Git -> View Branch History.
    • Right click the commit that you would like to keep
    • Choose Reset -> Keep Changes (--mixed). This option retains all changes from the previous commit
    • Note: If you would like to remove all changes from previous commit, choose Delete Changes (--hard) instead

    Git Reset

  2. If you need to edit your changes, make them as your desire & commit the changes before moving on.

  3. Force Push into the remote repo

    • Open up "Package Manager Console", via Tools -> NuGet Package Manager -> Package Manager Console Package Manager Console menu
    • Type "git push -f". The "-f" is important, as this means forced push. A normal push will prompt Visual Studio to Pull then Push as your local branch is now "behind" the the remote branch Git push
  4. Double check your remote repository's branch history to ensure the old commit is removed.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by thebernardlim


Print Share Comment Cite Upload Translate Updates
APA

thebernardlim | Sciencx (2023-01-13T03:03:15+00:00) Git – How to edit or remove a “pushed” commit using Visual Studio. Retrieved from https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/

MLA
" » Git – How to edit or remove a “pushed” commit using Visual Studio." thebernardlim | Sciencx - Friday January 13, 2023, https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/
HARVARD
thebernardlim | Sciencx Friday January 13, 2023 » Git – How to edit or remove a “pushed” commit using Visual Studio., viewed ,<https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/>
VANCOUVER
thebernardlim | Sciencx - » Git – How to edit or remove a “pushed” commit using Visual Studio. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/
CHICAGO
" » Git – How to edit or remove a “pushed” commit using Visual Studio." thebernardlim | Sciencx - Accessed . https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/
IEEE
" » Git – How to edit or remove a “pushed” commit using Visual Studio." thebernardlim | Sciencx [Online]. Available: https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/. [Accessed: ]
rf:citation
» Git – How to edit or remove a “pushed” commit using Visual Studio | thebernardlim | Sciencx | https://www.scien.cx/2023/01/13/git-how-to-edit-or-remove-a-pushed-commit-using-visual-studio/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.