Wednesday, July 14, 2021

Published July 14, 2021 by Anonymous with 0 comment

How to discard changes in Git

If you just want to clean unstaged changes on Git in your current working directory execute the following ‘Git discard all changes’ command ’:

git checkout — .

If however you are referring to a specific existing file, simply add the file path as follows :

git checkout — thepathtothefile/to/discard

Read: Git Fetch vs Pull

For newer Git releases however you would want to use the restore command :

git restore .                                         [Git discard changes command]

And for a specific file :

git restore thepathtothefile/to/discard               [Git revert changes for a file]

Answer due to Tobi.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

Adblock test (Why?)


Original page link

Best Cool Tech Gadgets

Top favorite technology gadgets
      edit

0 comments:

Post a Comment