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 6734415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:53:09+00:00 2026-05-26T10:53:09+00:00

how to discard git local branch changes? eg, local branch with version: A->B->C Now

  • 0

how to discard git local branch changes?
eg, local branch with version: A->B->C
Now I am on version A, and it has some changes conflict with latest version C.
I want to discard local changes and pull the latest version C.

$ git pull

I will meet some error. and there are many files, so I don’t need to do many times $ git co files

Is there any better way?

  • 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-26T10:53:10+00:00Added an answer on May 26, 2026 at 10:53 am

    If you have uncommitted changes that you want to discard, use this:

    $ git reset --hard
    

    which is equivalent to

    $ git reset --hard HEAD
    

    This removes all the local uncommitted changes. If you want to remove some offending commits from your local branch, try rewinding it:

    $ git reset --hard HEAD^ #moves HEAD back by one commit
    

    or e.g.

    $ git reset --hard HEAD~3 #moves HEAD back by 3 commits
    

    Use these with caution, as you won’t be able to undo these operations. Once you’re done cleaning up your local branch, use git pull to get the latest code.

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

Sidebar

Related Questions

I accidentially discard my changes on files in my local working tree via git
I want to discard all changes done after commit <commit-hash> . So I did:
git does not seem to do what I want here so I need some
In Git, is there a way to merge all changes from one branch into
How do I discard changes in my working copy that are not in the
I want to discard all remaining characters in a string as soon as one
git status # On branch master # Changed but not updated: # (use git
I have following working tree state $ git status foo/bar.txt # On branch master
By mistake I rm -rf a directory in my git repository. The changes are
I added some Haml templates to my Rails 3 project with git clone git://github.com/psynix/rails3_haml_scaffold_generator.git

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.