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 question.


Forgot Password?

Need An Account, Sign Up Here

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

Sign InSign Up

eHowToNow Forum

eHowToNow Forum Logo eHowToNow Forum Logo

eHowToNow Forum Navigation

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

Mobile menu

Close
Ask a Question
  • Meet The Team
  • Blog
  • About Us
  • Contact Us
Home/ Questions/Q 27400
Next
In Process
Vignesh
Vignesh

Vignesh

  • 1 Question
  • 0 Answers
  • 0 Best Answers
  • 2 Points
View Profile
  • 1
Vignesh
Asked: September 9, 20212021-09-09T14:30:25+00:00 2021-09-09T14:30:25+00:00In: Programming

How to delete unpushed changes in git

  • 1

I mistakenly committed my codes in wrong branch, those changes still in my local repository, not pushed to remote repository. I wan to revert all my unpushed changes, but I want all my local changes to be retained in local.

May I know the git command to fix this case

gitversion control
  • 2 2 Answers
  • 79 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. ehowtonow

    ehowtonow

    • 1 Question
    • 8 Answers
    • 2 Best Answers
    • 53 Points
    View Profile
    ehowtonow Teacher
    2021-09-10T06:52:42+00:00Added an answer on September 10, 2021 at 6:52 am

    Delete the most recent commit without loosing your changes, use below command (–soft is optional – by default it will use –soft reset)

    git reset –soft HEAD~1

    Delete the most recent commit changes you made in local will be lost, use below command

    git reset –hard HEAD~1

    If you have made more than one commit, want to reset all the commits but want to retain your local changes, use below command

    git reset –soft origin/<branch>

    If you have made more than one commit, want to reset all the commits and don’t want to retain your local changes, use below command (This will sync your local repo with origin branch)

    git reset –hard origin/<branch>

    • 1
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
    • Ganesh

      Ganesh

      • 2 Questions
      • 1 Answer
      • 0 Best Answers
      • 4 Points
      View Profile
      Ganesh
      2021-09-10T08:01:33+00:00Replied to answer on September 10, 2021 at 8:01 am

      How to apply created patch to new branch ? we tried to merge two branch using patch
      If some knows the ans please reply to my question

      How to merge two branches in Git

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Stats

  • Questions 66
  • Answers 12
  • Best Answers 2
  • Users 32
  • Popular
  • Answers
  • smartrader

    com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of

    • 2 Answers
  • Vignesh

    How to delete unpushed changes in git

    • 2 Answers
  • shilpa

    How to split the String by space

    • 1 Answer
  • Newton Alarcao
    Newton Alarcao added an answer I have an additional question. In the problem I submitted… April 3, 2022 at 2:48 pm
  • Ganesh
    Ganesh added an answer How to apply created patch to new branch ? we… September 10, 2021 at 8:01 am
  • ehowtonow
    ehowtonow added an answer Delete the most recent commit without loosing your changes, use… September 10, 2021 at 6:52 am

Related Questions

  • Ganesh

    How to merge two branches in Git

    • 0 Answers
  • Ganesh

    How to create patch from git

    • 0 Answers

Top Members

ehowtonow

ehowtonow

  • 1 Question
  • 53 Points
Teacher
Appu

Appu

  • 1 Question
  • 44 Points
Begginer
Newton Alarcao

Newton Alarcao

  • 1 Question
  • 21 Points
Begginer
MaheshKannan

MaheshKannan

  • 0 Questions
  • 20 Points
Begginer
Annamalai T

Annamalai T

  • 0 Questions
  • 20 Points
Begginer

Trending Tags

aadhar angular angularjs apache poi bufferedimage cmda core java database docker dtcp education encumbrance certificate excel parser excel parsing git government graphics2d gui hibernate how to draw thicker line to emphasize sudoku boxes jackson java java image java string jpa json k8s kubernetes material design maven medicine minikube orm pom xml ration card real estate regex regular expression trading vaccine version control xml xpath வில்லங்க சான்றிதழ்

Explore

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

Footer

eHowToNow Forum

eHowToNow.com forum is a social questions & Answers Engine which will help you establish your community and connect with other people.

About Us

  • Meet The Team
  • Blog
  • About Us
  • Contact Us

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2021 eHowToNow.com. All Rights Reserved

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.