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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:33:01+00:00 2026-05-27T15:33:01+00:00

Normally when you: git checkout foo Modify a file git checkout bar Git will

  • 0

Normally when you:

  1. git checkout foo
  2. Modify a file
  3. git checkout bar

Git will tell you that you can’t change branches because you have un-committed modifications. (I don’t have the exact message in front of me, but it’s something to that effect). You then normally use git stash to get rid of those modifications, and you’re on your merry way.

My coworker (who is new to Git and therefore is not intentionally doing anything advanced) doesn’t have that behavior. On her machine, when she does git checkout bar, it just moves the modifications that she made on foo into bar. This is very confusing to me, as I’ve been using Git for at least a year now and never seen it behave that way.

What could my coworker possibly have done to make it so that Git simply moves un-added/un-committed modified files between branches, rather than complaining and requiring git stash?

  • 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-27T15:33:02+00:00Added an answer on May 27, 2026 at 3:33 pm

    (I just wrote up the following text here for coworkers yesterday who are new to Git. Hope it helps.)

    If you have made changes to files on branch A and want to switch to branch B (which is unrelated), then it’s a good idea to commit the changes to branch A first. This way, the changes will still be on branch A when you come back to it later. (Another option is called “stashing”, which is useful in some situations – see http://schacon.github.com/git/git-stash.html for more information.)

    If you don’t commit the changes first, then there are two situations that can arise. Consider a file “file.txt”, and branches A and B. The two situations are:

    1. The latest version of file.txt on branch A and branch B is identical. In this case, a “git checkout B” will carry over the changes to file.txt to your working directory after successfully switching to branch B. This can be useful for things like changes to platform configuration files. Git will list the files carried over in this way in the output of the “git checkout” command.
    2. The latest versions of file.txt on branch A and branch B are different. When you ask to switch branches to branch B, git will refuse to switch branches because doing so would overwrite your changes to file.txt. You’ll get a message from git saying that you must commit (or stash) the conflicting file(s) first.

    If you have more than one changed file, then any file in situation (2) will prevent a branch switch.

    Finally, if you want to discard modifications to a file, use a command like “git checkout — file.txt”. This will throw away any uncommitted modifications to file.txt and restore it to the latest committed version from your current branch.

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

Sidebar

Related Questions

I have a Git repo that has been acting funny. I can checkout all
Normally you create a function using cfscript like: <cfscript> function foo() { return bar;
I'm working on a project that is being versioned with svn. Normally with git,
I'm wondering if I can tell git to resolve conflicts by appending their code
I know that normally there are no problems using Git from different OSs to
So I ran this command: git checkout -b --track origin/RB_1.4.5 I thought that it
Let's pretend I have a project directory that isn't a git repository. This project
Normally you can do this: <select size=3> <option>blah</option> <option>blah</option> <option>blah</option> </select> And it would
Normally I create web application projects and use code-behind, but I have a requirement
Normally, when I start up a new application, I'd create a new git repository

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.