• Home
  • Insurance
  • Banking
  • Loans
  • Remitance
  • About us
Facebook Twitter Instagram
  • links
Biz Assurance
Subscribe
  • Home
  • Insurance
  • Banking
  • Loans
  • Remitance
  • About us
Biz Assurance
Home»Tech»How to Undo a Particular Commit in Git that’s Been Pushed to Remote Repos
Tech

How to Undo a Particular Commit in Git that’s Been Pushed to Remote Repos

Alicia CormieBy Alicia CormieNo Comments3 Mins Read
Facebook Twitter WhatsApp
Share
Facebook Twitter LinkedIn WhatsApp

Git is one of the most common and versatile tracking tools which is easy to use. Developers can use it in their troubles when they commit undesirable modifications to a local repository. Sometimes, they want to undo the entire commit with all added changes instead of going through them manually. It might be possible these changes have been pushed to the centralized repository. For this purpose, a simple user can reset the HEAD pointer by utilizing the “git reset” command.

This post will discuss how to undo a particular commit in Git, which is pushed to the remote repository.

How to Undo a Desired Commit in Git that’s Been Pushed to GitHub server?

Try the below-stated instructions to undo the particular commit in Git, which is pushed to the remote repository:

  • Switch to the desired local repository.
  • List repository content that needs to push to the remote server.
  • Check the remote URL list.
  • Push data to the GitHub server.
  • Display the log history.
  • Type out the “git reset HEAD~” command.
  • Verify by viewing the Git commit history.

Step 1: Navigate to Git Desired Repository

Type out the “cd” command and navigate to the particular local repository:

$ cd “C:UsersnazmaGitperk6″

Step 2: List Repositories’ Content

Now, display the list of existing content by running the “ls” command:

$ ls

Step 3: Show Remote URL

Next, execute the provided command to show the available remote URL:

$ git remote -v

Step 4: Push Local Changes to Remote

Then, push all the modified data into the remote repository by executing the “git push” command:

$ git push -u origin feature

Here, the “origin” is the remote URL name, and “-u” represents the upstream branch. As you can see, all local data is pushed to the GitHub server:

Step 5: View Log History

To check the log history of the current working branch, run the “git log” command:

$ git log –oneline -5

According to the below-given output, the HEAD is pointing to the “6f3c…” commit SHA-hash:

Step 6: Reset HEAD Position

After that, use the following command to reset the HEAD position and revert the applied changes on the Git repository:

$ git reset HEAD~

Step 7: View Log History

Now, view the log history of the current working local branch by utilizing the “git log” command:

$ git log –oneline -5

As you can see, the HEAD position is changed to the previous commit, the currently pushed commit is removed from the history and changes are undo:

That’s all! You have learned how to undo the particular commit in Git, which is pushed to the remote repository.

Conclusion

To undo the particular commit in Git, which is pushed to the remote repository, first, move to the desired local repository and list its content to be pushed to the remote server. Then, check the remote URL list and push data to the GitHub server. After that, view the log history and run the “git reset HEAD~” command. Lastly, verify it by viewing the Git reference log history. This post described the procedure of undoing a particular commit in Git, which is pushed to the remote repository.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleHow to Terminate the Script in JavaScript
Next Article HTML- HTML5 Email Validation

Related Posts

How to Fix “Not connected – No connections are available” Error in Windows

How to Fix “Blurry Font Problem” in Windows 10

How to Fix “Can’t create new folder” in Windows 10

Add A Comment

Leave A Reply Cancel Reply

Grimes Explained Why She’s ‘Purposefully’ Trying To Make Herself ‘Infinitely Less Accessible’

It Appears That Netflix May Have Edited One Of Chris Rock’s Jokes About Will Smith In His Comedy Special

There’s A Rumor That Cardi B And Megan Thee Stallion Want To Remake A Cult-Classic Halle Berry Movie And Cardi Addressed It

The Biggest Takeaways From ‘Bel-Air’ Season 2, Episode 3

  • Homepage
  • Sitemap
© 2023 Biz Assurance - Designed by Curtiex Ventures.

Type above and press Enter to search. Press Esc to cancel.