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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:21:13+00:00 2026-06-01T09:21:13+00:00

I accidentally saved a file on the wrong branch. Then I did git reset

  • 0

I accidentally saved a file on the wrong branch. Then I did git reset --soft HEAD^ and now git status says I’m behind by 14 commits and lists a bunch of modified files in red. Including some untracked files.

I have no idea what to do. I tried to go to the latest commit from the remote repo but it says my local changes would be overwritten after I do git pull.

Help. I don’t wanna mess up my local repo even more. I just want to get back to the state I was in, save the edited file in the correct branch, and commit.

  • 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-01T09:21:14+00:00Added an answer on June 1, 2026 at 9:21 am

    If you have changed your local branch, and do not want to lose any change, you can use git-stash. Before any attempt, I recommend you to backup your local repository. Try the following steps:

    1. git stash save 'local changes'.
      This will save your local changes in a temporary place, and let you work on the current branch without any of these previous changes.

    2. git pull <remote-name> <branch-name>. As you already know, it will retrieve newer commits from the remote branch, and apply to your local branch.

    3. git stash pop. This will revert what you did in step 1. It will apply your previous changes (those you saved) against the local branch. You are responsible for resolving any conflicts, if any occur. Once done, you may want to commit, and push – it’s up to you.

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

Sidebar

Related Questions

I accidentally added a binary file to SVN with the add command, and now
I accidentally ran git merge some_other_branch on my local master branch. I haven't pushed
I really need this command in git hg addremove So now look at scenario
I type really fast and sometimes accidentally save a file with the name consisting
Using Windows XP I accidentally typed git commit -a instead of git commit -am My
I accidentally unpacked a gem (paperclip) in my root folder. Now I can't get
We accidentally merged branch XYZ into DEV and pushed it to the origin repo.
Sometimes I accidentally leave blank lines at the end of the file I am
I accidentally merged a branch into a workspace with applied patches. How do I
Accidentally I may forget to describe some parameters or exception throwing (or something else)

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.