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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:19:12+00:00 2026-05-27T05:19:12+00:00

After making a few changes to branch master I decided to work from a

  • 0

After making a few changes to branch master I decided to work from a new branch. I did git checkout -b new_branch_name and a new branch was created and checked out. git status showed the changes I had made to master.

I was curious if my changes were now on both branches (master and new_branch_name) or just new_branch_name. So I checked out master and noticed my changes were there as well. So I reverted those changes with git checkout -- fileThatChanged. The changes were indeed gone from master.

Unfortunately checking out new_branch_name and running git status showed my changes were reverted from that branch as well.

I’d like to understand what happened and how can I avoid this in the future.

One solution is to just create/checkout a new branch before starting work.

  • 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-27T05:19:13+00:00Added an answer on May 27, 2026 at 5:19 am

    You had never committed your changes to either branch. That is, if you did this:

    $ git status
    

    And saw something like this:

    # On branch master
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #   modified:   myfile.txt
    #
    

    The changes to “myfile.txt” do not “exist” on any branch — they are only in your local working copy. They don’t end up on a branch until you have comitted them to a repository.

    If at this point I were to type:

    $ git checkout myfile.txt
    

    This would obliterate my changes (and return the file to whatever it looked like in the last commit on my current branch).

    If I wanted to commit these changes on a new branch, I might do something like this:

    $ git checkout -b new_branch_name
    $ git add myfile.txt
    $ git commit -m "made some changes"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After making some changes in my models (eg. new field in a model and
After making a few changes to my already-deployed Grails app, I attempted to recompile
After making a few changes in my application, my textures are no longer showing.
After making a few modifications to a rails app I am tinkering on, railroad
After seeing a previous post Making Applications programmed in .NET languages work on older
I tried using the AWS console, but after making a few 100 files public
Consider this situation...You're just making changes to few files at once. The code isn't
I am attempting to integrate an existing payment platform into my webshop. After making
Django is making very nice forms after creating a models.py and an admin.py. How
After having had a dev PC HD corrupt, I'm considering the idea of making

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.