Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6762367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:18:57+00:00 2026-05-26T14:18:57+00:00

How do I perform the equivalent of the TFS ‘Undo pending changes’ in Git,

  • 0

How do I perform the equivalent of the TFS ‘Undo pending changes’ in Git, on one or multiple files?

That basically means to do these steps:

  • Undo changes on disk
  • Resetting any changes Git has discovered
  • Getting the latest changes on the file from Git

It would be good to know the differences (if there are any) in commands for doing this if you’ve (1) just changed it on disk, without adding it, but also when you’ve (2) done the add-command and for a bonus, (3) even when you have commit the change.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:18:58+00:00Added an answer on May 26, 2026 at 2:18 pm

    For 1 and 2, all you need to do is:

     git stash -u #same effect as git reset --hard, but can be undone
    

    this will throw away any changes. Be careful if you use reset. Read up on manipulating the index and the permutations of the hard, soft and mixed options with the reset and checkout. The progit book explains this in detail: http://progit.org/2011/07/11/reset.html

    For 3,

     git reset --hard HEAD^
    

    but would be better to issue a git stash -u before this – just in case you have pending changes.

    This will reset the current branch to the parent of the current commit. Look up “tree-ish” online. ^ and ~N after a reference will allow you to point to any reachable points in the history of that reference. To understand how history is tracked in git, “Git for computer scientists” explains the Directed Acyclic Graph well: http://eagain.net/articles/git-for-computer-scientists/

    To get individual files from the state of the current commit (ie, throw away changes), you can use checkout

    git checkout HEAD -- <a list of files>
    

    If you issued the last reset command above in error, you’re not in trouble. Git keeps track of where the branches used to point in the reflog.

    git reflog
    

    will list you the history. You can see in that output how to reference each, so:

    git reset --hard HEAD@{1}
    

    will reset the branch to where it used to be 1 change before.

    To add, if you want to wipe ignored files and untracked files, you can wipe with this:

    git clean -xdf
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to perform an SQL query that is logically equivalent to the following:
How can I perform the equivalent of this? My understanding is that this is
In Haskell there are two functions that allow one to perform an operation on
How do you perform the equivalent of Oracle's DESCRIBE TABLE in PostgreSQL with psql
I've been attempting to write a Lisp macro that would perfom the equivalent of
We perform updates of large text files by writing new records to a temp
How do I perform a reverse DNS lookup, that is how do I resolve
I'm setting up a project to use TFS on a server that I've configured,
In looking up how to perform an equivalent to SELECT TOP 5 with LINQ-to-SQL,
In Python, how do I perform the equivalent of the following import http.client but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.