Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all the local files and download a fresh copy from git [duplicate]

Tags:

git

I understand it is possible to delete everything locally and just start fresh but I wonder if there is an easier way when you do not require to keep anything done locally using git commands.

for example if I added bunch of files locally that I would like to remove and just download the latest master copy.

Please note: Reading the other questions (there are many; I read them before posting), git help & blog posts I wasn't sure if it's going to reset my repository or not which is why I posted this question; I imagine someone with the same exact issue might want to validate and that's what I have done through comments. and that is why I don't think its a duplicate although it might have the same response.

like image 581
Ash Avatar asked Dec 20 '25 08:12

Ash


1 Answers

To remove the git commit which you have added locally do:

git reset --hard HEAD^

To remove the remove the uncommitted files, do:

git clean -fd

check out other git Clean options here:

https://git-scm.com/docs/git-clean

and then do

git fetch
git rebase origin/master

or

   git pull
like image 103
insomiac Avatar answered Dec 22 '25 00:12

insomiac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!