Messing up with branches, old master branch shows files from the new branch?

As you can understand I’m still learning Git and how branch works. Anyways:

  1. I was working on a local master branch.
  2. I created and switched to a new fcwdetection branch for adding some code, using my IDE, meaning not through the command line.
  3. The IDE has asked me to add new files I created (say A.php) to the repository. I’ve added it and modified B.php (which was already added).

The result is that the master branch (I switched back to it) has now A.php and B.php has the same edits as B.php in fcwdetection branch.

  • How can I translate trunk/branch concepts from Subversion to Git?
  • Is there a way to make a branch invisible in TFS?
  • How do I manage conflicts with git submodules?
  • how can I figure out when a branch in git was merged into the trunk
  • Difference in GIT betw. branch, clone and snapshot
  • Unable to rename git branch to “master”, pushes to remote with incorrect name
  • How is this possible? Is this an error from the IDE or I completely misunderstood how branch work?

  • How do I update my local repo without losing my already committed changes?
  • in git, if fix applied to one version, how it is applied to later versions?
  • Can't push after Git Update
  • public repository with gitolite
  • setting up git in a private server, it asks for git password
  • Git - Unmerge after other commits have been made
  • One Solution collect form web for “Messing up with branches, old master branch shows files from the new branch?”

    Your workflow seems correct. Looks like an error in the IDE. If you want to have the modified files only in the fcwdetection branch you should commit them while you’re in that branch.
    In the command line you do something like that:

    Create the branch:

    git checkout -b fcwdetection
    

    Edit A.php and create B.php
    Add all the files, included the new B.php to git:

    git add -A .
    

    Commit them in the fcwdetection:

    git commit -m 'Commit message'
    

    At this point if you check back in master you see the old versions of the files:

    git checkout master
    

    If you keep seeing the the modified versions of A.php and B.php you should check their state, are them already added to the index? I say so beause git don’t let you switch from a branch to another with modified non-commited files, in the command line you get this error:

    error: Your local changes to the following files would be overwritten by checkout:
    [some files]
    Please, commit your changes or stash them before you can switch branches.
    
    Aborting
    
    Git Baby is a git and github fan, let's start git clone.