0

I am using EGit in Eclipse. I have one local repository with a Working directory and two branches. I have create a branch based on the master branch. I have added a folder and a file in the folder in the "secondary" branch. When i switch to the master branch, the folder i have created in the other branch and the files are showing up in the master branch and in the working directory.

Did i miss something? According to me it shouldnt show up and only when i push the secondary branch to the master one.

Could you please help on that

Regards

pam
  • 676
  • 1
  • 7
  • 27

1 Answers1

1

Creating something in the filesystem (for example with mkdir or touch) doesn't mean anything in Git. Once you commit the changeset, a new Commit object is created, and HEAD points to that commit on the current branch (possibly different from the default one, master). As long as you don't commit anything, your filesystem objects (file and directories) are not tracked by Git; instead, they effectively float around, so when you git checkout SOMETHING you end up with the new (untracked) objects or maybe an error message.

Raffaele
  • 20,627
  • 6
  • 47
  • 86
  • Ok, when i switch branch i see in my eclipse project explorer that it has correctly switched branch but whatever i do my eclipse explorer will directly work to what is consider the "working directory" in the local repository. Is it normal that i work directly in this directory? Lets say i have clone a repo and decide to create a secondary branch. What shall i do then to have those change saved (new folder, new files) in this secondary branch but not that it doesnt appear when i switch back to master branch. – pam Sep 12 '12 at 16:12
  • Switch to the secondary branch, do your work, then commit as normal (right click on the file/directory). This way your edits are saved in the experimental branch, and when you checkout another revision they disappear – Raffaele Sep 12 '12 at 16:21