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

  • Home
  • SEARCH
  • 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 8608161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:32:19+00:00 2026-06-12T03:32:19+00:00

I have downloaded a repository with git clone <address> i have made some modification

  • 0

I have downloaded a repository with

git clone <address>

i have made some modification and have edited some files, now i want to discard everything and just be sure that what i have on the disk is nothing else than the original remote version of the codebase: what is the right command ?

  • 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-06-12T03:32:20+00:00Added an answer on June 12, 2026 at 3:32 am

    Here is the long explanation so that you understand what is going on:

    Assuming the remote is called origin

    git reset --hard HEAD
    git checkout origin/master
    git branch -D master
    git checkout -b master
    

    What this does is:

    1. (Optional if git status says no modified files) Discard any modified files on the disk (that’s why reset --hard)

    2. Checkout the remote master branch (note: you will be in a “detatched head” state)

    3. Delete the local master branch (throwing away all your local changes)

    4. Call the current head as the new master branch

    Now you probably want to do something slightly different… i.e. don’t throw away your changes , just put them on another named branch… after all you never know when you’ll need them again

    git checkout -b my-silly-changes
    git branch -D master
    git checkout -b master origin/master
    

    That saves your current changes in a new local branch called my-silly-changes and then removes the old local branch called master and finally recreates it from the remote head.

    And here is the explanation for people who think they know what they are doing:

    The single command:

    git reset --hard origin/master
    

    Will discard any local changes and re-point the current branch to the most recently fetched state of origin/master. This has the exact same effect as the four commands at the start of this answer, but without looking behind the curtain

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Earlier I have downloaded Linux kernel from the git repository. Now I am trying
I'm looking to take an existing git repository where I have some code, download
have downloaded page by webbrowser and need to get mail address. But it is
I have downloaded and installed ActivePerl on my Windows 7-64 machine. Everything went smooth,
I downloaded Git and GitX for mac and installed it. Now, just for fun,
I have a large git repository that I am hosting with Dreamhost. It has
I have cloned a Git project into a local Git repository. Then I have
I have a git repository online and I use, as many do, to keep
I've downloaded scalaz snapshot from repository (version 6.0.4). I want to create standalone jar
I downloaded a 3rd party project as non-tracked files (without .git folder) and started

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.